From 05dc944a168c11d27e4252b07751d91a691877ca Mon Sep 17 00:00:00 2001 From: lei <1402328968@qq.com> Date: Sat, 16 Mar 2019 15:54:45 +0800 Subject: [PATCH 1/5] karma --- karma.conf.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ test/.travis.yml | 9 ++++++ test/test.js | 8 ++++++ 3 files changed, 88 insertions(+) create mode 100644 karma.conf.js create mode 100644 test/.travis.yml diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..fa9447b4 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,71 @@ +// Karma configuration +// Generated on Sat Mar 16 2019 15:32:59 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/.travis.yml b/test/.travis.yml new file mode 100644 index 00000000..f2630ce9 --- /dev/null +++ b/test/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - "8" +git: + submodules: false +install: + - npm install +test: + - npm run test \ No newline at end of file diff --git a/test/test.js b/test/test.js index 7c01938c..5a1c5db2 100644 --- a/test/test.js +++ b/test/test.js @@ -32,5 +32,13 @@ 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({ + url:'https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js', + type:'GET', + success:function(data){ + done(); + }, + }) + }) }) \ No newline at end of file From 9f184b0770e4490d6e2238433f2605494fd66f1e Mon Sep 17 00:00:00 2001 From: lei <1402328968@qq.com> Date: Sat, 16 Mar 2019 16:08:23 +0800 Subject: [PATCH 2/5] travis --- test/.travis.yml => .travis.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/.travis.yml => .travis.yml (100%) diff --git a/test/.travis.yml b/.travis.yml similarity index 100% rename from test/.travis.yml rename to .travis.yml From d068bf5feed5ac8987586bac7d1c647353ac87df Mon Sep 17 00:00:00 2001 From: lei <1402328968@qq.com> Date: Sat, 16 Mar 2019 16:20:30 +0800 Subject: [PATCH 3/5] jquery --- karma.conf.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index fa9447b4..2c4e43a6 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -15,7 +15,8 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'https://cdn.bootcss.com/jquery/2.2.4/jquery.js', + // 'https://cdn.bootcss.com/jquery/2.2.4/jquery.js', + 'node_modules/jquery/dist/jquery.js', 'node_modules/should/should.js', 'test/**.js' ], diff --git a/package.json b/package.json index 71c96b0c..0bec0826 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "homepage": "https://github.com/FE-star/exercise3#readme", "devDependencies": { + "jquery": "^3.3.1", "karma": "^1.7.0", "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", From e3983188fc49bc41d5a9bac8b963d7a1da11a71c Mon Sep 17 00:00:00 2001 From: lei <1402328968@qq.com> Date: Sat, 16 Mar 2019 16:25:01 +0800 Subject: [PATCH 4/5] ChromeHeadless --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 2c4e43a6..9f6d7785 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -58,7 +58,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['Chrome'], + browsers: ['ChromeHeadless'], // Continuous Integration mode From 9ff801e54415e870b759c158b3b64cc1b40294ba Mon Sep 17 00:00:00 2001 From: sanshixiong <81763816@qq.com> Date: Tue, 19 Mar 2019 19:44:54 +0800 Subject: [PATCH 5/5] Update karma.conf.js --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 9f6d7785..7348324e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -63,7 +63,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