Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Wallaby.js config for ng-cli generated project. The config file needs to be in the project root. Works faster with Electron runner: https://wallabyjs.com/docs/integration/electron.html
module.exports = function (wallaby) {
const compilerOptions = require('./src/tsconfig.json').compilerOptions;
compilerOptions.noEmitOnError = false;
return {
files: [
{pattern: 'node_modules/es6-shim/es6-shim.js', instrument: false},
{pattern: 'node_modules/systemjs/dist/system-polyfills.js', instrument: false},
{pattern: 'node_modules/reflect-metadata/Reflect.js', instrument: false},
{pattern: 'node_modules/systemjs/dist/system.js', instrument: false},
{pattern: 'node_modules/rxjs/bundles/Rx.js', instrument: false},
{pattern: 'node_modules/zone.js/dist/zone.js', instrument: false},
{pattern: 'node_modules/zone.js/dist/async-test.js', instrument: false},
{pattern: 'src/system-config.ts', instrument: false},
{pattern: 'src/app/**/*.ts', load: false},
{pattern: 'src/app/**/*.html', load: false},
{pattern: 'src/app/**/*.css', load: false},
{pattern: 'src/app/**/*.spec.ts', ignore: true}
],
tests: [{pattern: 'src/app/**/*.spec.ts', load: false}],
preprocessors: {
// see https://github.com/wallabyjs/public/issues/632#issuecomment-224205605
'src/system-config.ts': file => file.content
.replace(/vendor/g, 'node_modules')
.replace(/app\//g, 'src\/app\/')
},
compilers: {
'**/*.ts': wallaby.compilers.typeScript(compilerOptions)
},
middleware: function (app, express) {
app.use('/node_modules', express.static(require('path').join(__dirname, 'node_modules')));
},
setup: function (wallaby) {
wallaby.delayStart();
System.config({
defaultJSExtensions: true
});
var promises = [];
Promise.all([System.import('@angular/core/testing'), System.import('@angular/platform-browser-dynamic/testing')])
.then(function (results) {
var testing = results[0];
var browser = results[1];
testing.setBaseTestProviders(
browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
);
for (var i = 0, len = wallaby.tests.length; i < len; i++) {
promises.push(System['import'](wallaby.tests[i].replace(/\.js$/, '')));
}
})
.then(function () {
return Promise.all(promises);
})
.then(function () {
wallaby.start();
})
.catch(function (e) {
setTimeout(function () {
throw e;
}, 0);
});
},
debug: true
};
};
@zpydee

This comment has been minimized.

Show comment Hide comment
@zpydee

zpydee May 17, 2016

Tried pushing up to a branch for a PR, but have no access.
Consider adding:
{pattern: 'src/app/**/*.css', load: false},
and change
tests: [{pattern: 'src/app/*.spec.ts', load: false}], to tests: [{pattern: 'src/app/**/*.spec.ts', load: false}],

zpydee commented May 17, 2016

Tried pushing up to a branch for a PR, but have no access.
Consider adding:
{pattern: 'src/app/**/*.css', load: false},
and change
tests: [{pattern: 'src/app/*.spec.ts', load: false}], to tests: [{pattern: 'src/app/**/*.spec.ts', load: false}],

@ArtemGovorov

This comment has been minimized.

Show comment Hide comment
@ArtemGovorov

ArtemGovorov May 26, 2016

Thanks, edited the config.

Owner

ArtemGovorov commented May 26, 2016

Thanks, edited the config.

@danimbrogno

This comment has been minimized.

Show comment Hide comment
@danimbrogno

danimbrogno Sep 20, 2016

Tried this out but received error that System was undefined. I installed system-js, and now I see error:

Uncaught Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:49200/@angular/core/testing.js
    Error: XHR error (404 Not Found) loading http://localhost:49200/@angular/core/testing.js
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:647:29)
        at ZoneDelegate.invokeTask (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:236:37)
        at Zone.runTask (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:136:47)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:304:33)
    Error loading http://localhost:49200/@angular/core/testing.js

Any advice?

Tried this out but received error that System was undefined. I installed system-js, and now I see error:

Uncaught Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:49200/@angular/core/testing.js
    Error: XHR error (404 Not Found) loading http://localhost:49200/@angular/core/testing.js
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:647:29)
        at ZoneDelegate.invokeTask (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:236:37)
        at Zone.runTask (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:136:47)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:49200/node_modules/zone.js/dist/zone.js?1474390371804&wallabyFileId=5:304:33)
    Error loading http://localhost:49200/@angular/core/testing.js

Any advice?

@danimbrogno

This comment has been minimized.

Show comment Hide comment
@danimbrogno

danimbrogno Sep 20, 2016

Just noticed the file "src/system-config.ts" is missing. How is this generated?

Just noticed the file "src/system-config.ts" is missing. How is this generated?

@danimbrogno

This comment has been minimized.

Show comment Hide comment
@danimbrogno

danimbrogno Sep 20, 2016

Ahh, guessing this config is for the version of angular2-cli before it switched over to webpack builds. Any chance you have a config for angular2-cli + webpack?

Ahh, guessing this config is for the version of angular2-cli before it switched over to webpack builds. Any chance you have a config for angular2-cli + webpack?

@danimbrogno

This comment has been minimized.

Show comment Hide comment
@danimbrogno

danimbrogno Sep 20, 2016

nevermind! Just discovered the example config here

nevermind! Just discovered the example config here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment