Skip to content

Commit

Permalink
Revert "test setup for ESM support"
Browse files Browse the repository at this point in the history
This reverts commit dc12bd5.
  • Loading branch information
Bamieh committed Jan 3, 2018
1 parent dc12bd5 commit c3281a1
Show file tree
Hide file tree
Showing 5 changed files with 2,022 additions and 8,512 deletions.
16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ NYC := "node_modules/.bin/nyc"

ifdef COVERAGE
define test_node
$(NYC) --no-clean --report-dir coverage/reports/$(1) $(MOCHA)
$(NYC) --no-clean --report-dir coverage/reports/$(1) $(MOCHA)
endef
else
test_node := $(MOCHA)
test_node := $(MOCHA)
endif

TM_BUNDLE = JavaScript\ mocha.tmbundle
Expand Down Expand Up @@ -37,7 +37,7 @@ lint:

test-node: test-bdd test-tdd test-qunit test-exports test-unit test-integration test-jsapi test-compilers test-requires test-reporters test-only test-global-only

test-browser: clean mocha.js test-browser-unit test-browser-bdd test-browser-qunit test-browser-tdd test-browser-esm
test-browser: clean mocha.js test-browser-unit test-browser-bdd test-browser-qunit test-browser-tdd test-browser-exports

test: lint test-node test-browser

Expand All @@ -47,19 +47,15 @@ test-browser-unit:

test-browser-bdd:
@printf "==> [Test :: Browser :: BDD]\n"
MOCHA_TEST=bdd $(MAKE) test-browser-unit
MOCHA_UI=bdd $(MAKE) test-browser-unit

test-browser-qunit:
@printf "==> [Test :: Browser :: QUnit]\n"
MOCHA_TEST=qunit $(MAKE) test-browser-unit
MOCHA_UI=qunit $(MAKE) test-browser-unit

test-browser-tdd:
@printf "==> [Test :: Browser :: TDD]\n"
MOCHA_TEST=tdd $(MAKE) test-browser-unit

test-browser-esm:
@printf "==> [Test :: Browser :: ESM]\n"
MOCHA_TEST=esm $(MAKE) test-browser-unit
MOCHA_UI=tdd $(MAKE) test-browser-unit

test-jsapi:
@printf "==> [Test :: JS API]\n"
Expand Down
85 changes: 34 additions & 51 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ module.exports = config => {
.ignore('path')
.ignore('supports-color')
.on('bundled', (err, content) => {
if (err) {
throw err;
}
if (bundleDirpath) {
if (!err && bundleDirpath) {
// write bundle to directory for debugging
fs.writeFileSync(path.join(bundleDirpath,
`mocha.${Date.now()}.js`), content);
`bundle.${Date.now()}.js`), content);
}
});
}
Expand All @@ -63,8 +60,18 @@ module.exports = config => {
}
};

// TO RUN AGAINST SAUCELABS LOCALLY, execute:
// `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> make test-browser`
// see https://github.com/saucelabs/karma-sauce-example

// We define the browser to run on the Saucelabs Infrastructure
// via the environment variables BROWSER and PLATFORM.
// PLATFORM is e.g. "Windows"
// BROWSER is expected to be in the format "<name>@<version>",
// e.g. "MicrosoftEdge@latest"
// See https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
// for available browsers.

// TO RUN LOCALLY, execute:
// `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> BROWSER=<browser> PLATFORM=<platform> make test-browser`
const env = process.env;
let sauceConfig;

Expand All @@ -85,7 +92,8 @@ module.exports = config => {
console.error('No SauceLabs credentials present');
}
} else if (env.APPVEYOR) {
throw new Error('no browser tests should run on AppVeyor!');
console.error('AppVeyor detected');
bundleDirpath = path.join(baseBundleDirpath, process.env.APPVEYOR_BUILD_ID);
} else {
console.error('Local/unknown environment detected');
bundleDirpath = path.join(baseBundleDirpath, 'local');
Expand All @@ -112,48 +120,21 @@ module.exports = config => {
addSauceTests(cfg);
}

/* the MOCHA_TEST env var will be set for "special" cases of tests.
* these may require different interfaces or other setup which make
* them unable to be batched w/ the rest.
*/
const MOCHA_TEST = env.MOCHA_TEST;
switch (MOCHA_TEST) {
case 'bdd':
case 'tdd':
case 'qunit':
if (cfg.sauceLabs) {
cfg.sauceLabs.testName = `Interface "${MOCHA_TEST}" Integration Tests`;
}
cfg.files = [
`test/browser-fixtures/${MOCHA_TEST}.fixture.js`,
`test/interfaces/${MOCHA_TEST}.spec.js`
];
break;

case 'esm':
// for now we will only run against Chrome to test this.
if (cfg.sauceLabs) {
cfg.sauceLabs.testName = 'ESM Integration Tests';
cfg.browsers = ['chrome@latest'];
cfg.customLaunchers = {
'chrome@latest': cfg.customLaunchers['chrome@latest']
};
} else if (!env.TRAVIS) {
cfg.browsers = ['Chrome'];
} else {
console.error(
'skipping ESM tests & exiting; no SauceLabs nor local run detected');
process.exit(0);
}
cfg.files = [
'test/browser-fixtures/esm.fixture.html',
'test/browser-specific/esm.spec.js'
];
break;
default:
if (cfg.sauceLabs) {
cfg.sauceLabs.testName = 'Unit Tests';
}
// the MOCHA_UI env var will determine if we're running interface-specific
// tests. since you can only load one at a time, each must be run separately.
// each has its own set of acceptance tests and a fixture.
// the "bdd" fixture is used by default.
const ui = env.MOCHA_UI;
if (ui) {
if (cfg.sauceLabs) {
cfg.sauceLabs.testName = `Interface "${ui}" integration tests`;
}
cfg.files = [
`test/browser-fixtures/${ui}.fixture.js`,
`test/interfaces/${ui}.spec.js`
];
} else if (cfg.sauceLabs) {
cfg.sauceLabs.testName = 'Unit Tests';
}

config.set(cfg);
Expand All @@ -165,7 +146,9 @@ function addSauceTests (cfg) {
cfg.browsers = cfg.browsers.concat(browsers);
cfg.customLaunchers = browsers.reduce((acc, browser) => {
const platform = browserPlatformPairs[browser];
const [browserName, version] = browser.split('@');
const browserParts = browser.split('@');
const browserName = browserParts[0];
const version = browserParts[1];
acc[browser] = {
base: 'SauceLabs',
browserName: browserName,
Expand Down

0 comments on commit c3281a1

Please sign in to comment.