Skip to content

Commit

Permalink
fix(build): do not load tslib twice in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pimenovoleg committed Jan 9, 2019
1 parent 5785949 commit eed1270
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions tests/karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;

__karma__.loaded = function () {};

var specFiles = Object.keys(window.__karma__.files).filter(isMaterialSpecFile);
var specFiles = Object.keys(window.__karma__.files).filter(isMosaicSpecFile);

// Configure the Angular test bed and run all specs once configured.
configureTestBed()
.then(runMaterialSpecs)
.then(runMosaicSpecs)
.then(__karma__.start, function(error) {
// Passing in the error object directly to Karma won't log out the stack trace and
// passing the `originalErr` doesn't work correctly either. We have to log out the
Expand All @@ -22,16 +22,16 @@ configureTestBed()
});


/** Runs the Angular Material specs in Karma. */
function runMaterialSpecs() {
/** Runs the specs in Karma. */
function runMosaicSpecs() {
// By importing all spec files, Karma will run the tests directly.
return Promise.all(specFiles.map(function(fileName) {
return System.import(fileName);
}));
}

/** Whether the specified file is part of Angular Material. */
function isMaterialSpecFile(path) {
/** Whether the specified file is part lib. */
function isMosaicSpecFile(path) {
return path.slice(-8) === '.spec.js' && path.indexOf('node_modules') === -1;
}

Expand All @@ -58,7 +58,7 @@ function configureTestBed() {
* destruction are thrown instead of silently logged. Also runs TestBed.resetTestingModule after
* each unit test.
*
* Without this patch, the combination of two behaviors is problematic for Angular Material:
* Without this patch, the combination of two behaviors is problematic for Mosaic:
* - TestBed.resetTestingModule catches errors thrown on fixture destruction and logs them without
* the errors ever being thrown. This means that any component errors that occur in ngOnDestroy
* can encounter errors silently and still pass unit tests.
Expand Down
2 changes: 1 addition & 1 deletion tests/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = (config) => {
],
files: [
{pattern: 'node_modules/core-js/client/core.min.js', included: true, watched: false},
{pattern: 'node_modules/tslib/tslib.js', included: true, watched: false},
{pattern: 'node_modules/tslib/tslib.js', included: false, watched: false},
{pattern: 'node_modules/systemjs/dist/system.js', included: true, watched: false},
{pattern: 'node_modules/zone.js/dist/zone.min.js', included: true, watched: false},
{pattern: 'node_modules/zone.js/dist/proxy.min.js', included: true, watched: false},
Expand Down

0 comments on commit eed1270

Please sign in to comment.