Skip to content

Commit 1c7c38d

Browse files
authored
Merge branch 'next' into renovate/major-typescript
2 parents 1b20a92 + ed36f5c commit 1c7c38d

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import webpackPreprocessor from '@cypress/webpack-preprocessor';
22
import { defineConfig } from 'cypress';
33

44
export default defineConfig({
5+
allowCypressEnv: false,
56
video: false,
67
e2e: {
78
chromeWebSecurity: false,

cypress/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES2015",
4+
"moduleResolution": "bundler",
45
"lib": ["ES2015", "DOM"],
56
"types": ["cypress"],
67
"noEmit": true,

docs/guide/upgrading.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,39 @@ As mentioned in the previous section, CJS can still be used if you use a modern
4747

4848
Previously, you were able to provide the values `"Bundler"`, `"Node10"`, `"Node16"` or `"NodeNext"` for the configuration `"moduleResulution"`. Starting in v10 of Faker, only the values `"Bundler"`, `"Node20"` or `"NodeNext"` are supported for your CJS codebase. [To use `"Node20"` your **`typescript` version must be at least `5.9.0`**](https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/#support-for---module-node20).
4949

50-
#### Incompatibility with Jest
50+
#### Jest
5151

52-
Because the [Jest](https://www.npmjs.com/package/jest) testing library uses its own module resolution system, there are known compatibility issues with Faker v10 in combination with CJS in Jest tests.
52+
Because [Jest](https://www.npmjs.com/package/jest) testing library uses its own module resolution system, there are known compatibility issues with Faker v10 in combination with CJS in the Jest tests.
5353

54-
For now, keep using Faker v9, or see possible workarounds in [issue #3606](https://github.com/faker-js/faker/issues/3606).
54+
If any below solutions fails, keep using Faker v9. You can find some more details and possible workarounds in [issue #3606](https://github.com/faker-js/faker/issues/3606).
55+
56+
##### `ts-jest`
57+
58+
When using Jest in a TypeScript project you might be already using `ts-jest` for transforming `ts` files on the fly. In such case you should apply following changes to your `jest.config.ts`:
59+
60+
```ts
61+
// Transform both `ts` and `js` files. Defining only `ts` would not be enough, as we also need to transform @faker-js
62+
transform: {
63+
'^.+\\.(t|j)s$': 'ts-jest',
64+
65+
// or when you pass more settings:
66+
'^.+\\.(t|j)s$': [
67+
'ts-jest',
68+
// ... other setttings
69+
]
70+
}
71+
72+
// Exclude from transformation all files in `node_modules`, except `@faker-js`
73+
transformIgnorePatterns: [
74+
// npm
75+
'node_modules/(?!@faker-js).+',
76+
77+
// pnpm
78+
'node_modules/.pnpm/.+/node_modules/(?!@faker-js).+'
79+
],
80+
```
81+
82+
Check more in our [playground](https://github.com/faker-js/playground/blob/main/playgrounds/jest-cjs/jest.config.js).
5583

5684
### Removal of Deprecated Code
5785

0 commit comments

Comments
 (0)