Skip to content

Commit

Permalink
Run browser tests via Karma instead of custom phantomjs runner (#1352)
Browse files Browse the repository at this point in the history
* Run browser tests in Firefox instead of in PhantomJS

* Continue to use PhantomJS, but via karma instead of custom runner
  • Loading branch information
jeskew authored Feb 10, 2017
1 parent 2b45e4d commit 044852c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ cache:

before_install:
- "if [[ `node -v` == v0.8.* ]]; then npm install -g npm || exit 0; fi"
- "export PATH=$PWD/travis-phantomjs:$PATH"
- "phantomjs --version"
- "if [ $(phantomjs --version) != '2.0.0' ]; then rm -rf $PWD/travis-phantomjs; mkdir -p $PWD/travis-phantomjs; fi"
- "if [ $(phantomjs --version) != '2.0.0' ]; then wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2; fi"
- "if [ $(phantomjs --version) != '2.0.0' ]; then tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs; fi"
- "phantomjs --version"

script:
- "if [ $INTEGRATION ]; then cucumber.js -f pretty; else npm test; fi"
Expand Down
21 changes: 21 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Karma configuration
// Generated on Wed Feb 08 2017 17:56:27 GMT-0800 (PST)

module.exports = function(config) {
config.set({
frameworks: ['jasmine'],
files: [
'test/browser/build/aws-sdk-all.js',
'test/browser/build/tests.js'
],
reporters: ['progress'],
port: 19876,
colors: false,
logLevel: config.LOG_ERROR,
browsers: ['PhantomJS'],
singleRun: true,
browserDisconnectTolerance: 3,
browserNoActivityTimeout: 30000,
concurrency: 1
})
};
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"eslint": "1.x",
"insert-module-globals": "^7.0.0",
"istanbul": "*",
"jasmine": "^2.5.3",
"jasmine-core": "^2.5.2",
"karma": "^1.4.1",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.2",
"mocha": "*",
"repl.history": "*",
"semver": "*",
Expand Down Expand Up @@ -108,7 +113,7 @@
"test": "npm -s run-script lint && npm -s run-script unit && npm -s run-script buildertest && npm -s run-script browsertest && ([ -f configuration ] && npm -s run-script integration || true)",
"unit": "istanbul `[ $COVERAGE ] && echo 'cover _mocha' || echo 'test mocha'` -- test test/json test/model test/protocol test/query test/services test/signers test/xml test/s3 test/cloudfront test/dynamodb test/polly",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- test test/json test/dynamodb test/cloudfront test/model test/protocol test/query test/services test/signers test/xml",
"browsertest": "rake browser:test",
"browsertest": "rake browser:test && karma start",
"buildertest": "mocha --compilers coffee:coffee-script -s 1000 -t 10000 dist-tools/test",
"integration": "cucumber.js",
"lint": "eslint lib dist-tools/*.js",
Expand All @@ -117,4 +122,4 @@
"tstest": "tsc -p ./ts",
"add-change": "node ./scripts/changelog/add-change.js"
}
}
}
2 changes: 0 additions & 2 deletions tasks/browser.rake
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ namespace :browser do
" -t coffeeify -i domain #{files} > #{$BROWSERIFY_TEST}")
rm_f "test/helpers.js"
rm_f "test/configuration.js"
sh "open test/browser/runner.html" if ENV['OPEN']
sh "phantomjs test/browser/runner.js"
end

task :dist_path do
Expand Down
6 changes: 4 additions & 2 deletions test/sequential_executor.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@ describe 'AWS.SequentialExecutor', ->
@emitter.emit('event1')
expect(list).to.eql([1,2,3])

it 'does not stop emitting when error is returned', ->
it 'does not stop emitting when error is returned', (done) ->
list = []
@emitter.on 'event1', -> list.push(1)
@emitter.on 'event1', -> list.push(2); throw 'error'
@emitter.on 'event1', -> list.push(3)
@emitter.emit 'event1', [null], (err) ->
expect(err.message).to.eql('error')
expect(list).to.eql([1,2,3])
done()

it 'does not stop emitting when error is returned (async)', ->
it 'does not stop emitting when error is returned (async)', (done) ->
list = []
@emitter.on 'event1', -> list.push(1)
@emitter.onAsync 'event1', (err, done) -> list.push(2); done('ERROR')
@emitter.on 'event1', -> list.push(3)
@emitter.emit 'event1', [null], (err) ->
expect(err.message).to.equal('ERROR')
expect(list).to.eql([1,2,3])
done()

0 comments on commit 044852c

Please sign in to comment.