@@ -38,10 +38,13 @@ module.exports = config => {
3838 . ignore ( 'path' )
3939 . ignore ( 'supports-color' )
4040 . on ( 'bundled' , ( err , content ) => {
41- if ( ! err && bundleDirpath ) {
41+ if ( err ) {
42+ throw err ;
43+ }
44+ if ( bundleDirpath ) {
4245 // write bundle to directory for debugging
4346 fs . writeFileSync ( path . join ( bundleDirpath ,
44- `bundle .${ Date . now ( ) } .js` ) , content ) ;
47+ `mocha .${ Date . now ( ) } .js` ) , content ) ;
4548 }
4649 } ) ;
4750 }
@@ -60,18 +63,8 @@ module.exports = config => {
6063 }
6164 } ;
6265
63- // see https://github.com/saucelabs/karma-sauce-example
64-
65- // We define the browser to run on the Saucelabs Infrastructure
66- // via the environment variables BROWSER and PLATFORM.
67- // PLATFORM is e.g. "Windows"
68- // BROWSER is expected to be in the format "<name>@<version>",
69- // e.g. "MicrosoftEdge@latest"
70- // See https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
71- // for available browsers.
72-
73- // TO RUN LOCALLY, execute:
74- // `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> BROWSER=<browser> PLATFORM=<platform> make test-browser`
66+ // TO RUN AGAINST SAUCELABS LOCALLY, execute:
67+ // `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> make test-browser`
7568 const env = process . env ;
7669 let sauceConfig ;
7770
@@ -92,8 +85,7 @@ module.exports = config => {
9285 console . error ( 'No SauceLabs credentials present' ) ;
9386 }
9487 } else if ( env . APPVEYOR ) {
95- console . error ( 'AppVeyor detected' ) ;
96- bundleDirpath = path . join ( baseBundleDirpath , process . env . APPVEYOR_BUILD_ID ) ;
88+ throw new Error ( 'no browser tests should run on AppVeyor!' ) ;
9789 } else {
9890 console . error ( 'Local/unknown environment detected' ) ;
9991 bundleDirpath = path . join ( baseBundleDirpath , 'local' ) ;
@@ -120,21 +112,48 @@ module.exports = config => {
120112 addSauceTests ( cfg ) ;
121113 }
122114
123- // the MOCHA_UI env var will determine if we're running interface-specific
124- // tests. since you can only load one at a time, each must be run separately.
125- // each has its own set of acceptance tests and a fixture.
126- // the "bdd" fixture is used by default.
127- const ui = env . MOCHA_UI ;
128- if ( ui ) {
129- if ( cfg . sauceLabs ) {
130- cfg . sauceLabs . testName = `Interface "${ ui } " integration tests` ;
131- }
132- cfg . files = [
133- `test/browser-fixtures/${ ui } .fixture.js` ,
134- `test/interfaces/${ ui } .spec.js`
135- ] ;
136- } else if ( cfg . sauceLabs ) {
137- cfg . sauceLabs . testName = 'Unit Tests' ;
115+ /* the MOCHA_TEST env var will be set for "special" cases of tests.
116+ * these may require different interfaces or other setup which make
117+ * them unable to be batched w/ the rest.
118+ */
119+ const MOCHA_TEST = env . MOCHA_TEST ;
120+ switch ( MOCHA_TEST ) {
121+ case 'bdd' :
122+ case 'tdd' :
123+ case 'qunit' :
124+ if ( cfg . sauceLabs ) {
125+ cfg . sauceLabs . testName = `Interface "${ MOCHA_TEST } " Integration Tests` ;
126+ }
127+ cfg . files = [
128+ `test/browser-fixtures/${ MOCHA_TEST } .fixture.js` ,
129+ `test/interfaces/${ MOCHA_TEST } .spec.js`
130+ ] ;
131+ break ;
132+
133+ case 'esm' :
134+ // for now we will only run against Chrome to test this.
135+ if ( cfg . sauceLabs ) {
136+ cfg . sauceLabs . testName = 'ESM Integration Tests' ;
137+ cfg . browsers = [ 'chrome@latest' ] ;
138+ cfg . customLaunchers = {
139+ 'chrome@latest' : cfg . customLaunchers [ 'chrome@latest' ]
140+ } ;
141+ } else if ( ! env . TRAVIS ) {
142+ cfg . browsers = [ 'Chrome' ] ;
143+ } else {
144+ console . error (
145+ 'skipping ESM tests & exiting; no SauceLabs nor local run detected' ) ;
146+ process . exit ( 0 ) ;
147+ }
148+ cfg . files = [
149+ 'test/browser-fixtures/esm.fixture.html' ,
150+ 'test/browser-specific/esm.spec.js'
151+ ] ;
152+ break ;
153+ default :
154+ if ( cfg . sauceLabs ) {
155+ cfg . sauceLabs . testName = 'Unit Tests' ;
156+ }
138157 }
139158
140159 config . set ( cfg ) ;
@@ -146,9 +165,7 @@ function addSauceTests (cfg) {
146165 cfg . browsers = cfg . browsers . concat ( browsers ) ;
147166 cfg . customLaunchers = browsers . reduce ( ( acc , browser ) => {
148167 const platform = browserPlatformPairs [ browser ] ;
149- const browserParts = browser . split ( '@' ) ;
150- const browserName = browserParts [ 0 ] ;
151- const version = browserParts [ 1 ] ;
168+ const [ browserName , version ] = browser . split ( '@' ) ;
152169 acc [ browser ] = {
153170 base : 'SauceLabs' ,
154171 browserName : browserName ,
0 commit comments