Skip to content

Commit

Permalink
fix(typescript): Fix Jest for ESM/CJS (#5560)
Browse files Browse the repository at this point in the history
Fix Jest for ESM/CJS
  • Loading branch information
Swimburger authored Jan 9, 2025
1 parent d53fcd8 commit 7e831ae
Show file tree
Hide file tree
Showing 190 changed files with 753 additions and 459 deletions.
5 changes: 5 additions & 0 deletions generators/typescript/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.46.2] - 2025-01-09

- Fix: Fix Jest to work with files imported using `.js` extension.
- Fix: Make sure Jest loads Jest configuration regardless of package.json type.

## [0.46.1] - 2025-01-08

- Fix: ESModule output is fixed to be compatible with Node.js ESM loading.
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.46.1
0.46.2
3 changes: 2 additions & 1 deletion generators/typescript/sdk/cli/src/SdkGeneratorCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ export class SdkGeneratorCli extends AbstractGeneratorCli<SdkCustomConfig> {
pathToSrc: persistedTypescriptProject.getSrcDirectory(),
pathToRoot: persistedTypescriptProject.getRootDirectory()
});
await this.postProcess(persistedTypescriptProject);

const scriptsManager = new ScriptsManager();
await scriptsManager.copyScripts({
pathToRoot: persistedTypescriptProject.getRootDirectory()
});
await this.postProcess(persistedTypescriptProject);

return persistedTypescriptProject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ export class JestTestGenerator {

private addJestConfig(): void {
const jestConfig = this.rootDirectory.createSourceFile(
"jest.config.js",
"jest.config.mjs",
code`
/** @type {import('jest').Config} */
module.exports = {
export default {
preset: "ts-jest",
testEnvironment: "node",
moduleNameMapper: {
'(.+)\\.js': '$1'
}
};
`.toString({ dprintOptions: { indentWidth: 4 } })
// globalSetup: "<rootDir>/tests/setup.js",
Expand Down
6 changes: 4 additions & 2 deletions seed/ts-express/version/.mock/definition/api.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/audiences/no-custom-config/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/audiences/no-custom-config/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/audiences/with-partner-audience/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/audiences/with-partner-audience/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/auth-environment-variables/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/auth-environment-variables/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/basic-auth-environment-variables/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/basic-auth-environment-variables/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/basic-auth/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/basic-auth/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/bearer-token-environment-variable/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/bearer-token-environment-variable/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/bytes/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/bytes/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/circular-references-advanced/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/circular-references-advanced/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/circular-references/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/circular-references/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/cross-package-type-names/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/cross-package-type-names/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/custom-auth/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/custom-auth/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/enum/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/enum/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/error-property/union-utils/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/error-property/union-utils/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/examples/retain-original-casing/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/examples/retain-original-casing/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/exhaustive/allow-extra-fields/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/exhaustive/allow-extra-fields/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/exhaustive/bigint/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/exhaustive/bigint/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/exhaustive/bundle/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/exhaustive/bundle/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/exhaustive/custom-package-json/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/exhaustive/custom-package-json/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions seed/ts-sdk/exhaustive/dev-dependencies/jest.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions seed/ts-sdk/exhaustive/dev-dependencies/jest.config.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7e831ae

Please sign in to comment.