From 947156573fd506f640e17404238500d72081cb0a Mon Sep 17 00:00:00 2001 From: MartinsYong Date: Tue, 23 Jul 2019 21:24:46 +0800 Subject: [PATCH] DONE --- .travis.yml | 14 ++++++++++ karma.conf.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 ++- test/test.js | 7 ++++- 4 files changed, 94 insertions(+), 2 deletions(-) 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..68956194 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: node_js + +node_js: +- '8' + +branches: + only: + - master + +install: +- npm install + +script: +- npm run travis \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..a1329abd --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,71 @@ +// Karma configuration +// Generated on Tue Jul 23 2019 20:27:34 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: [ + 'test/**.js', + 'https://cdn.bootcss.com/jquery/2.2.4/jquery.js', + 'node_modules/should/should.js' + ], + + + // list of files / patterns 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/package.json b/package.json index 71c96b0c..48829167 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "test", "main": "index.js", "scripts": { - "test": "karma start" + "test": "karma start", + "travis": "karma start --single-run --browsers PhantomJS" }, "repository": { "type": "git", @@ -23,6 +24,7 @@ "karma": "^1.7.0", "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", + "karma-phantomjs-launcher": "^1.0.4", "mocha": "^3.5.0", "should": "^11.2.1" } diff --git a/test/test.js b/test/test.js index 7c01938c..71ddc6ea 100644 --- a/test/test.js +++ b/test/test.js @@ -31,6 +31,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,并验证是否拿到文件 + this.timeout(5000); + // 使用 jQuery.ajax 请求 https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js,并验证是否拿到文件 + var url = 'https://raw.githubusercontent.com/FE-star/exercise1/master/test/test.js'; + $.get(url, function () { + done() + }) }) }) \ No newline at end of file