From f4fad232566ffb45038bbd4f03521f026e33803f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=95=8F?= Date: Sat, 16 Mar 2019 09:07:01 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=80=9A=E8=BF=87=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- karma.conf.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/test.js | 7 +++++ 2 files changed, 78 insertions(+) create mode 100644 karma.conf.js diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..68f0e573 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,71 @@ +// Karma configuration +// Generated on Thu Mar 14 2019 10:30:19 GMT+0800 (CST) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha'], + + + // list of files / patterns to load in the browser + files: [ + 'https://cdn.bootcss.com/jquery/2.2.4/jquery.js', + 'node_modules/should/should.js', + 'test/**.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }) +} diff --git a/test/test.js b/test/test.js index 7c01938c..1400fc7b 100644 --- a/test/test.js +++ b/test/test.js @@ -32,5 +32,12 @@ describe('jQuery', function () { it('should able to request https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js', function (done) { // 使用 jQuery.ajax 请求 https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js,并验证是否拿到文件 + window.jQuery.ajax({ + url: 'https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js', + type: 'GET', + success: function () { + done(); + } + }) }) }) \ No newline at end of file From d075d3b96681afaa74fb2ffeb2b2766ff1816d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=95=8F?= Date: Sat, 16 Mar 2019 09:37:07 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=BB=91=E5=AE=9Atravis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..cbafdc08 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +before_script: npm install +script: npm run test \ No newline at end of file From 8da1b900f92f8105f4e56cbb8069cee1e8aa1502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=95=8F?= Date: Sat, 16 Mar 2019 09:43:35 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9travis.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cbafdc08..01ccd056 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,45 @@ +sudo: false language: node_js -before_script: npm install -script: npm run test \ No newline at end of file +node_js: + - 8 + - 10 + +env: + global: + - SAUCE_USERNAME: karmarunnerbot + - secure: "bRVY+hYZwMf1SqVnMyZRJTLD0gN1hLx9/MwO8MM/qBiu3YNjXy49XElfMdzMKN6cZeKTmhcnjmZonbJuI1PQ2t+utGkyjnlVLJ/OlWptreKLzIlcbt4hrdPoTcjmUTwDWq9Ex9cVoYX8AzCasETttpczp3P+s3+vmOUj8z25JyU=" + - CXX=g++-4.8 +matrix: + fast_finish: true + include: + - name: "Lint code and commit message format" + node_js: "8" + env: VALIDATE_COMMIT_MSG=true LINT=true + +before_install: + - npm config set loglevel warn + - g++-4.8 --version + +addons: + firefox: + "latest" + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - npm run init + - export $(openssl aes-256-cbc -pass env:CREDENTIALS_PASS -d -in credentials) + - echo "TRAVIS_COMMIT $TRAVIS_COMMIT" + - echo "TRAVIS_PULL_REQUEST_SHA $TRAVIS_PULL_REQUEST_SHA" + - COMMIT_TO_VALIDATE=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} + - echo "COMMIT_TO_VALIDATE $COMMIT_TO_VALIDATE" + - 'if [ "$VALIDATE_COMMIT_MSG" == "true" ]; then ./scripts/validate-commit-msg.sh $COMMIT_TO_VALIDATE; fi' + - 'if [ "$LINT" == "true" ]; then npm run lint; fi' + +script: + - npm run travis \ No newline at end of file From 88d7fc94f59640074027121db7825443fabe5711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=95=8F?= Date: Sat, 16 Mar 2019 09:57:50 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9travis.yml=E5=92=8Ckarma.?= =?UTF-8?q?conf.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 46 +++------------------------------------------- karma.conf.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01ccd056..93b2d1a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,45 +1,5 @@ -sudo: false language: node_js -node_js: - - 8 - - 10 - -env: - global: - - SAUCE_USERNAME: karmarunnerbot - - secure: "bRVY+hYZwMf1SqVnMyZRJTLD0gN1hLx9/MwO8MM/qBiu3YNjXy49XElfMdzMKN6cZeKTmhcnjmZonbJuI1PQ2t+utGkyjnlVLJ/OlWptreKLzIlcbt4hrdPoTcjmUTwDWq9Ex9cVoYX8AzCasETttpczp3P+s3+vmOUj8z25JyU=" - - CXX=g++-4.8 -matrix: - fast_finish: true - include: - - name: "Lint code and commit message format" - node_js: "8" - env: VALIDATE_COMMIT_MSG=true LINT=true - -before_install: - - npm config set loglevel warn - - g++-4.8 --version - +before_script: npm install +script: npm run test addons: - firefox: - "latest" - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 - -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - - npm run init - - export $(openssl aes-256-cbc -pass env:CREDENTIALS_PASS -d -in credentials) - - echo "TRAVIS_COMMIT $TRAVIS_COMMIT" - - echo "TRAVIS_PULL_REQUEST_SHA $TRAVIS_PULL_REQUEST_SHA" - - COMMIT_TO_VALIDATE=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} - - echo "COMMIT_TO_VALIDATE $COMMIT_TO_VALIDATE" - - 'if [ "$VALIDATE_COMMIT_MSG" == "true" ]; then ./scripts/validate-commit-msg.sh $COMMIT_TO_VALIDATE; fi' - - 'if [ "$LINT" == "true" ]; then npm run lint; fi' - -script: - - npm run travis \ No newline at end of file + chrome: stable \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 68f0e573..940f034a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -57,8 +57,16 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['Chrome'], + browsers: ['Chrome', 'Chrome_without_security'], // You may use 'ChromeCanary', 'Chromium' or any other supported browser + + // you can define custom flags + customLaunchers: { + Chrome_without_security: { + base: 'Chrome', + flags: ['--disable-web-security'] + } + } // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits @@ -66,6 +74,7 @@ module.exports = function(config) { // Concurrency level // how many browser should be started simultaneous - concurrency: Infinity + concurrency: Infinity, + }) } From 96570c93b2c1aa182b7c32eb5c06efacd35c084b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=95=8F?= Date: Sat, 16 Mar 2019 11:41:22 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9karma.conf.js=20=3D>=20si?= =?UTF-8?q?ngleRun:=20true?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- karma.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 940f034a..2b8d4351 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -66,11 +66,11 @@ module.exports = function(config) { base: 'Chrome', flags: ['--disable-web-security'] } - } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: false, + singleRun: true, // Concurrency level // how many browser should be started simultaneous From 194d426a19186dab83a66fc15cac4127a8b7c9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=95=8F?= Date: Sat, 16 Mar 2019 11:45:22 +0800 Subject: [PATCH 6/6] update --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 93b2d1a3..7a819eed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: node_js +script: karma start --single-run +before_install: + - export CHROME_BIN=chromium-browser + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start before_script: npm install -script: npm run test addons: chrome: stable \ No newline at end of file