You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BREAKING CHANGE: add an alternative preset for babel and restructures
the whole repository to treat babel and ts-jest equally.
The jest config of users will have to be adjusted, see the CHANGELOG.md
for migration information.
Closes#308
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
## Changelog (master)
2
2
3
+
#### Features
4
+
* (**BREAKING**): Add preset `babel` as transpilation alternative to `ts-jest` ([#317](https://github.com/thymikee/jest-preset-angular/pull/317)).
5
+
6
+
#### Migration Guide
7
+
* The preset reference in the jest config has to be updated from `"jest-preset-angular"` to `"jest-preset-angular/build/ts-jest"`. To use babel, replace `ts-jest` with `babel`. Furthermore, when using `ts-jest`, it has to be added as `devDependency` to the project.
`babel` uses the babel compiler to generate JavaScript, without type-checking your test files before doing so. You can still do type-checking using `tsc --noEmit`. For additional TypeScript-supported language features you might have to install even more babel packages.
41
+
22
42
## Usage
23
43
24
44
In `src` directory create `setupJest.ts` file with following contents:
@@ -35,17 +55,42 @@ _Note: feel free to copy the [`jestGlobalMocks.ts`](https://github.com/thymikee/
By Angular CLI defaults you'll have a `src/test.ts` file which will be picked up by jest. To circumvent this you can either rename it to `src/karmaTest.ts` or hide it from jest by adding `<rootDir>/src/test.ts` to jest `testPathIgnorePatterns` option.
Note that the [babel preset](https://github.com/thymikee/jest-preset-angular/blob/master/src/babel/jest-preset.js) looks different.
127
+
81
128
### Brief explanation of config
82
129
83
130
-`<rootDir>` is a special syntax for root of your project (here by default it's project's root /)
84
131
- we're using some `"globals"` to pass information about where our tsconfig.json file is that we'd like to be able to transform HTML files through ts-jest
85
-
-`"transform"` – run every TS, JS, or HTML file through so called _preprocessor_ (we'll get there); this lets Jest understand non-JS syntax
132
+
-`"transform"` – run every TS, JS, or HTML file through so called _preprocessor_, in our case just `ts-jest` or `babel-jest`; this lets Jest understand non-JS syntax
86
133
-`"testMatch"` – we want to run Jest on files that matches this glob
87
134
-`"moduleFileExtensions"` – our modules are TypeScript and JavaScript files
88
135
-`"moduleNameMapper"` – if you're using absolute imports here's how to tell Jest where to look for them; uses regex
0 commit comments