Skip to content

Commit

Permalink
fix: Run functional tests with production npm dependencies on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rpl committed Sep 29, 2017
1 parent 88b4ead commit ba556cc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ before_script:

# Keep this in sync with appveyor.yml
script:
## run eslint, flow and the unit test suite.
- COVERAGE=y NODE_ENV=production npm test

## run functional test suite in a npm production environment
## (See #1082 for rationale).
- npm run copy:create-artifacts-production
- cd artifacts/production && npm install --production && cd -
- TEST_WEB_EXT_BIN=./artifacts/production/bin/web-ext npm run test:functional

## lint the github PR title.
- npm run travis-pr-title-lint

after_script: npm run publish-coverage
Expand Down
8 changes: 6 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ module.exports = function(grunt) {
'webpack:functional_tests',
]);

grunt.registerTask('test', 'run linting and test suites', function() {
grunt.registerTask('test', 'run linting and the unit test suite', function() {
var tasks = [
'lint',
'flowbin:check',
'build-tests',
'mochaTest:unit',
'mochaTest:functional',
];

// TODO: enable the flowbin:check task on AppVeyor (mozilla/web-ext#773)
Expand All @@ -48,6 +47,11 @@ module.exports = function(grunt) {
grunt.task.run(tasks);
});

grunt.registerTask('test:functional', 'run functional test suites', [
'build-tests',
'mochaTest:functional',
]);

grunt.registerTask('develop', [
'flowbin:start',
'watch:develop',
Expand Down
9 changes: 9 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ test_script:
- set COVERAGE=y
- set NODE_ENV=production
- npm run test
## install the eslint version needed by eslint and run functional test suite
## (See #1082 for rationale).
## run functional test suite in a npm production environment
## (See #1082 for rationale).
- npm run copy:create-artifacts-production
- cd artifacts\production
- npm install --production
- cd ..\..
- TEST_WEB_EXT_BIN=.\artifacts\production\bin\web-ext npm run test:functional
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"flow-check": "grunt flowbin:check",
"lint": "grunt lint",
"test": "grunt test",
"test:functional": "grunt test:functional:run",
"copy:create-artifacts-production": "grunt copy:create-artifacts-production",
"publish-coverage": "grunt coveralls",
"nsp-check": "nsp check -o summary",
"changelog": "conventional-changelog -p angular -u",
Expand Down
11 changes: 11 additions & 0 deletions tasks/configs/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'create-artifacts-production': {
files: [
{
expand: true,
src: ['package.json', 'dist/**', 'bin/**'],
dest: 'artifacts/production',
},
],
},
};
4 changes: 3 additions & 1 deletion tests/functional/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export const withTempDir = tmpDirUtils.withTempDir;

export const functionalTestsDir = path.resolve(__dirname);
export const projectDir = path.join(functionalTestsDir, '..', '..');
export const webExt = path.join(projectDir, 'bin', 'web-ext');
export const webExt = process.env.TEST_WEB_EXT_BIN ?
path.resolve(process.env.TEST_WEB_EXT_BIN) :
path.join(projectDir, 'bin', 'web-ext');
export const fixturesDir = path.join(functionalTestsDir, '..', 'fixtures');
export const minimalAddonPath = path.join(fixturesDir, 'minimal-web-ext');
export const fakeFirefoxPath = path.join(
Expand Down

0 comments on commit ba556cc

Please sign in to comment.