Skip to content

Commit 3c992a1

Browse files
authored
fix(presets): add mjs to the list of moduleFileExtensions (#1155)
Closes #1147
1 parent 1e7dbf8 commit 3c992a1

File tree

20 files changed

+76
-27
lines changed

20 files changed

+76
-27
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44

55
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
66

7-
87
## Test plan
98

109
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
1110

12-
1311
## Does this PR introduce a breaking change?
1412

1513
- [ ] Yes
1614
- [ ] No
1715

1816
<!-- If this PR contains a breaking change, please describe the impact and migration plan -->
1917

20-
2118
## Other information
22-

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
node_modules/
3+
src/**/__snapshots__/
4+
e2e/__tests__/__snapshots__/
5+
CHANGELOG.md

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ Adjust your `tsconfig.spec.json` to be:
7373
}
7474
```
7575

76-
## Notes on usage with Angular >=13
76+
## Migration from Angular < 13
7777

78-
Check out our [Angular >=13 usage notes](https://thymikee.github.io/jest-preset-angular/docs/next/guides/angular-13+)
78+
Check out our [Migration from Angular < 13 guidance](https://thymikee.github.io/jest-preset-angular/docs/next/guides/angular-13+)
7979

8080
## Angular Ivy
8181

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { json as runWithJson } from '../run-jest';
2+
3+
const DIR = 'ng-deep-import';
4+
5+
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
6+
const { json } = runWithJson(DIR);
7+
8+
expect(json.success).toBe(true);
9+
});
10+
11+
test(`successfully runs the tests inside ${DIR} with isolatedModules: true`, () => {
12+
const { json } = runWithJson(DIR, ['-c=jest-isolated.config.js']);
13+
14+
expect(json.success).toBe(true);
15+
});

e2e/async/jest-isolated.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const baseCfg = require('./jest.config');
33
module.exports = {
44
...baseCfg,
55
globals: {
6-
...baseCfg.globals['ts-jest'],
7-
isolatedModules: true,
6+
'ts-jest': {
7+
...baseCfg.globals['ts-jest'],
8+
isolatedModules: true,
9+
},
810
},
911
};

e2e/custom-typings/jest-isolated.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const baseCfg = require('./jest.config');
33
module.exports = {
44
...baseCfg,
55
globals: {
6-
isolatedModules: true,
6+
'ts-jest': {
7+
isolatedModules: true,
8+
},
79
},
810
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import localeFr from '@angular/common/locales/fr';
2+
3+
test('should work with deep import of Angular ESM package', () => {
4+
expect(localeFr).toBeDefined();
5+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const baseCfg = require('./jest.config');
2+
3+
module.exports = {
4+
...baseCfg,
5+
globals: {
6+
'ts-jest': {
7+
isolatedModules: true,
8+
},
9+
},
10+
};

e2e/ng-deep-import/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs'],
3+
resolver: '<rootDir>/../../build/resolvers/ng-jest-resolver.js',
4+
transform: {
5+
'^.+\\.(ts|js|mjs|html)$': '<rootDir>/../../build/index.js',
6+
},
7+
transformIgnorePatterns: ['node_modules/(?!@angular)'],
8+
};

0 commit comments

Comments
 (0)