Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options are not passed to transformer #7

Closed
PindaPixel opened this issue Dec 8, 2022 · 2 comments
Closed

Options are not passed to transformer #7

PindaPixel opened this issue Dec 8, 2022 · 2 comments

Comments

@PindaPixel
Copy link

When passing a tsconfig to ts-jest with chain transform it doesn't load the tsconfig file:

// tsconfig.base.json
{
    "compilerOptions": {
        "module": "ES2022",
        "target": "ES2022",
        "moduleResolution": "Node",
        "esModuleInterop": true,
        "strict": true
    }
}
// tsconfig.test.json
{
    "extends": "tsconfig.base.json",
    "compilerOptions": {
        "types": ["jest"]
    },
    "include": ["tests"]
}
// jest.config.ts
import type { JestConfigWithTsJest } from "ts-jest";

export default {
    transform: {
        "^.*(\\.|\\/)(test\\.ts)$": [
            "jest-chain-transform",
            {
                transformers: [
                    "jest-tsd-transform",
                    [
                        "ts-jest",
                        {
                            tsconfig: "tsconfig.test.json",
                        },
                    ],
                ],
            },
        ],
    },
    testMatch: ["<rootDir>/tests/**/*test.ts"],
} satisfies JestConfigWithTsJest;

Outputs:

ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.

If, instead, I use ts-jest without chain transform it loads my tsconfig correctly:

// jest.config.ts
import type { JestConfigWithTsJest } from "ts-jest";

export default {
    transform: {
        "^.*(\\.|\\/)(test\\.ts)$": [
            "ts-jest",
            {
                tsconfig: "tsconfig.test.json",
            },
        ],
    },
    testMatch: ["<rootDir>/tests/**/*test.ts"],
} satisfies JestConfigWithTsJest;
@anc95
Copy link
Owner

anc95 commented Dec 12, 2022

@PindaPixel please try 0.0.5 version. should fix this.

@PindaPixel
Copy link
Author

Wonderful! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants