Skip to content

Commit

Permalink
test(integration): Use node for running test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jan 8, 2019
1 parent a871b83 commit f2c30bb
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Expand Up @@ -11,6 +11,9 @@
"browser": true,
"es6": true,
"webextensions": true,

// The script gets processed by UMD, so we have access to CommonJS globals.
"commonjs": true,
},

"globals": {
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ script:
- echo "RE-RUN tests on the minified file" && npm run test-minified
- echo "RE-RUN tests on the webpack and browserify bundled files" &&
npm install -g browserify webpack webpack-cli &&
./scripts/run-module-bundlers-smoketests.sh
node ./scripts/run-module-bundlers-smoketests.js
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- echo "RUN integration tests on real browsers" &&
Expand Down
6 changes: 2 additions & 4 deletions Gruntfile.js
Expand Up @@ -2,13 +2,11 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";

/* eslint-env commonjs */

const LICENSE = `/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */`;

const MINIFIED_FILE_FOOTER = `\n\n// <%= pkg.name %> v.<%= pkg.version %> (<%= pkg.homepage %>)\n\n${LICENSE}`;
const MINIFIED_FILE_FOOTER = `\n// <%= pkg.name %> v.<%= pkg.version %> (<%= pkg.homepage %>)\n\n${LICENSE}\n`;

module.exports = function(grunt) {
grunt.initConfig({
Expand All @@ -22,7 +20,7 @@ module.exports = function(grunt) {

eslint: {
src: ["src/browser-polyfill.js", "Gruntfile.js"],
test: ["test/**/*.js"],
test: ["test/**/*.js", "scripts/**/*.js"],
},

replace: {
Expand Down
5 changes: 5 additions & 0 deletions scripts/.eslintrc
@@ -0,0 +1,5 @@
{
"env": {
"node": true,
},
}
22 changes: 13 additions & 9 deletions scripts/run-browsers-smoketests.js
@@ -1,20 +1,24 @@
#!/usr/bin/env node
const shell = require("shelljs");

// set -eo pipefail
let result = 0;

console.log(`
Test webextension-polyfill on real browsers
===========================================
`);
===========================================`);

// ## HEADLESS=1 Enable the headless mode (currently used only on Firefox
// ## because Chrome doesn't currently support the extensions in headless mode)
// Enable headless mode (currently only used when running on Firefox
// because Chrome doesn't currently support the extensions in headless mode)
process.env.HEADLESS = 1;

console.log("Runing smoketests on Chrome");
console.log(`
Runing smoketests on Chrome`);
process.env.TEST_BROWSER_TYPE = "chrome";
shell.exec("npm run test-integration:chrome");
result = shell.exec("npm run test-integration:chrome").code || result;

console.log("Running smoketests on Firefox");
console.log(`
Running smoketests on Firefox`);
process.env.TEST_BROWSER_TYPE = "firefox";
shell.exec("npm run test-integration:firefox");
result = shell.exec("npm run test-integration:firefox").code || result;

process.exit(result);
22 changes: 22 additions & 0 deletions scripts/run-module-bundlers-smoketests.js
@@ -0,0 +1,22 @@
#!/usr/bin/env node
const shell = require("shelljs");

let result = 0;

console.log(`
Test webextension-polyfill bundled with webpack
===============================================`);

shell.exec("webpack --mode production --entry ./test/fixtures/bundle-entrypoint.js --output /tmp/webpack-bundle.js");
process.env.TEST_BUNDLED_POLYFILL = "/tmp/webpack-bundle.js";
result = shell.exec("npm run test").code || result;

console.log(`
Test webextension-polyfill bundled with browserify
==================================================`);

shell.exec("browserify test/fixtures/bundle-entrypoint.js > /tmp/browserify-bundle.js");
process.env.TEST_BUNDLED_POLYFILL = "/tmp/browserify-bundle.js";
result = shell.exec("npm run test").code || result;

process.exit(result);
16 changes: 0 additions & 16 deletions scripts/run-module-bundlers-smoketests.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/browser-polyfill.js
Expand Up @@ -509,7 +509,7 @@ if (typeof browser === "undefined" || Object.getPrototypeOf(browser) !== Object.

// The build process adds a UMD wrapper around this file, which makes the
// `module` variable available.
module.exports = wrapAPIs(chrome); // eslint-disable-line no-undef
module.exports = wrapAPIs(chrome);
} else {
module.exports = browser; // eslint-disable-line no-undef
module.exports = browser;
}
7 changes: 2 additions & 5 deletions test/.eslintrc
Expand Up @@ -2,11 +2,8 @@
"env": {
"mocha": true,
"node": true,
"browser": true,
"webextensions": true
},
"globals": {},
"rules": {
"max-nested-callbacks": ["warn", 6]
}
"max-nested-callbacks": ["warn", 6],
},
}

0 comments on commit f2c30bb

Please sign in to comment.