-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(jest): move to jest backend for testing
remove all files linked to karma / jasmine
- Loading branch information
1 parent
65d2864
commit cd74a10
Showing
12 changed files
with
1,117 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
"globals": { | ||
"ts-jest": { | ||
"tsConfigFile": "src/tsconfig.spec.json" | ||
}, | ||
"__TRANSFORM_HTML__": true | ||
}, | ||
"transform": { | ||
"^.+\\.(ts|js|html)$": "<rootDir>/node_modules/jest-preset-angular/preprocessor.js", | ||
"^.+\\.js$": "babel-jest" | ||
}, | ||
"testMatch": [ | ||
"**/__tests__/**/*.+(ts|js)?(x)", | ||
"**/+(*.)+(spec|test).+(ts|js)?(x)" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js", | ||
"html", | ||
"json" | ||
], | ||
"moduleNameMapper": { | ||
"#app/(.*)": "<rootDir>/src/app/$1" | ||
}, | ||
"transformIgnorePatterns": [ | ||
"node_modules/(?!@ngrx|ng2-truncate)" | ||
], | ||
"snapshotSerializers": [ | ||
"<rootDir>/node_modules/jest-preset-angular/AngularSnapshotSerializer.js", | ||
"<rootDir>/node_modules/jest-preset-angular/HTMLCommentSerializer.js" | ||
], | ||
"preset": "jest-preset-angular", | ||
"setupTestFrameworkScriptFile": "<rootDir>/src/test.ts" | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files | ||
import 'jest-preset-angular'; | ||
|
||
import 'zone.js/dist/zone-testing'; | ||
import {getTestBed} from '@angular/core/testing'; | ||
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; | ||
// @ts-ignore | ||
global.CSS = null; | ||
|
||
declare var require: any; | ||
const webStorageMock = () => { | ||
let storage: Record<string, any> = {}; | ||
return { | ||
getItem: (key: string) => (key in storage ? storage[key] : null), | ||
setItem: (key: string, value: any) => (storage[key] = value || ''), | ||
removeItem: (key: string) => delete storage[key], | ||
clear: () => (storage = {}), | ||
}; | ||
}; | ||
|
||
// First, initialize the Angular testing environment. | ||
getTestBed().initTestEnvironment( | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting() | ||
); | ||
// Then we find all the tests. | ||
const context = require.context('./', true, /\.spec\.ts$/); | ||
// And load the modules. | ||
context.keys().map(context); | ||
Object.defineProperty(window, 'localStorage', { value: webStorageMock() }); | ||
Object.defineProperty(window, 'sessionStorage', { value: webStorageMock() }); | ||
Object.defineProperty(document, 'doctype', { | ||
value: '<!DOCTYPE html>', | ||
}); | ||
Object.defineProperty(window, 'getComputedStyle', { | ||
value: () => { | ||
return { | ||
display: 'none', | ||
appearance: ['-webkit-appearance'], | ||
}; | ||
}, | ||
}); | ||
/** | ||
* ISSUE: https://github.com/angular/material2/issues/7101 | ||
* Workaround for JSDOM missing transform property | ||
*/ | ||
Object.defineProperty(document.body.style, 'transform', { | ||
value: () => { | ||
return { | ||
enumerable: true, | ||
configurable: true, | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.