From eac4dba71f728355125baf54d38420bba8dd18e2 Mon Sep 17 00:00:00 2001 From: Outsider Date: Fri, 19 Jan 2018 23:22:29 +0900 Subject: [PATCH] extract checking AMD bundle as own test --- package-scripts.js | 13 ++++++++++++- scripts/travis-before-script.sh | 3 --- test/bundle/amd.spec.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 test/bundle/amd.spec.js diff --git a/package-scripts.js b/package-scripts.js index 7aa256d231..aee5463dbe 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -40,7 +40,7 @@ module.exports = { test: { default: 'nps test.all', all: { - script: 'nps lint.code test.node test.browser', + script: 'nps lint.code test.node test.browser test.bundle', description: 'Lint code and runs node / browser environment tests' }, node: { @@ -205,6 +205,17 @@ module.exports = { script: test('non-tty-dot', '--reporter spec test/interfaces/bdd.spec 2>&1 > /tmp/spec.out && echo "spec:" && cat /tmp/spec.out'), description: 'Test non-TTY spec reporter' } + }, + bundle: { + default: 'nps test.bundle.all', + all: { + script: 'nps clean build.mochajs test.bundle.amd', + description: 'Compile Mocha and run all tests for bundle files' + }, + amd: { + script: test('amd', 'test/bundle/amd.spec'), + description: 'Test bundle files for AMD' + } } }, coveralls: { diff --git a/scripts/travis-before-script.sh b/scripts/travis-before-script.sh index 19ebc4b13b..3e8a45c0bf 100755 --- a/scripts/travis-before-script.sh +++ b/scripts/travis-before-script.sh @@ -2,6 +2,3 @@ # bundle artifacts to AWS go here mkdir -p .karma - -# ensure we are building a non-broken bundle for AMD -npm start build.mochajs && [[ -z "$(grep 'define.amd' mocha.js)" ]] || exit 1 diff --git a/test/bundle/amd.spec.js b/test/bundle/amd.spec.js new file mode 100644 index 0000000000..e42d3dab0b --- /dev/null +++ b/test/bundle/amd.spec.js @@ -0,0 +1,14 @@ +'use strict'; + +var path = require('path'); +var fs = require('fs'); + +it('should build a non-broken bundle for AMD', function (done) { + var bundle = path.join(process.cwd(), 'mocha.js'); + fs.readFile(bundle, 'utf8', function (err, content) { + if (err) { return done(err); } + + expect(content).not.to.match(/define.amd/); + done(); + }); +});