From 7076c040c88124faeb5134a9b3ebafe8d5515364 Mon Sep 17 00:00:00 2001 From: chenshiyu Date: Mon, 29 Jul 2019 15:19:54 +0800 Subject: [PATCH 1/4] vivi/feat/exercise3 --- .travis.yml | 3 +++ karma.conf.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/test.js | 6 +++++ 3 files changed, 80 insertions(+) create mode 100644 .travis.yml create mode 100644 karma.conf.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..98c86f74 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "8" \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..d2241679 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,71 @@ +// Karma configuration +// Generated on Mon Jul 29 2019 14:08:08 GMT+0800 (中国标准时间) + +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..59d81e17 100644 --- a/test/test.js +++ b/test/test.js @@ -32,5 +32,11 @@ 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,并验证是否拿到文件 + $.ajax({ + type: 'GET', + url: 'https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js', + success: () => done(), + error: (err) => done(err), + }); }) }) \ No newline at end of file From dc2f8ee1a020199c901c0dd642541fa9ed0fba7c Mon Sep 17 00:00:00 2001 From: chenshiyu Date: Mon, 29 Jul 2019 15:41:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix/travis-ci=E6=8A=A5=E9=94=99=EF=BC=9ACan?= =?UTF-8?q?not=20start=20Chrome?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98c86f74..ebd679ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,7 @@ language: node_js node_js: - - "8" \ No newline at end of file + - "8" +before_install: + - export CHROME_BIN=chromium-browser + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start \ No newline at end of file From 5f53c600ca0bc9068a25be0f62bf1e7635650501 Mon Sep 17 00:00:00 2001 From: chenshiyu Date: Mon, 29 Jul 2019 16:05:50 +0800 Subject: [PATCH 3/4] fix/travis change script --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ebd679ec..42475c79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,6 @@ node_js: before_install: - export CHROME_BIN=chromium-browser - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start \ No newline at end of file + - sh -e /etc/init.d/xvfb start +script: + - npm run test --single-run \ No newline at end of file From b4d8e4b5d623f2cb5290615b9fd69bf759b6bf94 Mon Sep 17 00:00:00 2001 From: chenshiyu Date: Mon, 29 Jul 2019 16:19:50 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix/=E4=BF=AE=E6=94=B9karma.config.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index d2241679..c3585b47 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -62,7 +62,7 @@ module.exports = function(config) { // 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