Open jsoneaday opened 1 year ago
I have a very similar issue. Tests are running ok locally (windows and macos, not tried ubuntu), but in a Github Actions workflow, i have the following message:
FAIL src/__tests__/App.test.tsx
● Test suite failed to run
Unable to process '/home/runner/work/midi-jar/midi-jar/src/__tests__/App.test.tsx', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform /home/runner/work/midi-jar/midi-jar/src/__tests__/App.test.tsx
at TsCompiler.getCompiledOutput (node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js:173:27)
at TsJestCompiler.getCompiledOutput (node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js:14:39)
at TsJestTransformer.exports.TsJestTransformer.TsJestTransformer.processWithTs (node_modules/ts-jest/dist/legacy/ts-jest-transformer.js:265:37)
at TsJestTransformer.exports.TsJestTransformer.TsJestTransformer.process (node_modules/ts-jest/dist/legacy/ts-jest-transformer.js:188:[24](https://github.com/la-jarre-a-son/midi-jar/actions/runs/6013973240/job/16312644447#step:9:25))
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:545:31)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:7[26](https://github.com/la-jarre-a-son/midi-jar/actions/runs/6013973240/job/16312644447#step:9:27):19)
The test:
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import App from '../renderer/App';
describe('App', () => {
it('should render', () => {
expect(render(<App />)).toBeTruthy();
});
});
Versions:
"jest": "^29.6.4",,
"ts-jest": "^29.1.1",
Config:
{
"testEnvironment": "jsdom",
"testEnvironmentOptions": {
"url": "http://localhost/"
},
"transform": {"\\.[jt]sx?$": "ts-jest"},
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/.erb/mocks/fileMock.js",
"\\.(css|less|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json"
],
"moduleDirectories": [
"node_modules",
"release/app/node_modules",
"src"
],
"testMatch": [
"**/*.test.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"release/app/dist"
],
"setupFiles": [
"./.erb/scripts/check-build-exists.ts"
],
"setupFilesAfterEnv": [
"./src/__tests__/setup.ts"
]
}
TSConfig:
{
"compilerOptions": {
"incremental": true,
"target": "es2015",
"module": "commonjs",
"lib": ["dom", "es2021"],
"jsx": "react-jsx",
"strict": true,
"sourceMap": true,
"baseUrl": "./src",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"allowJs": true,
"skipLibCheck": true,
"outDir": ".erb/dll",
},
"exclude": ["release/build", "release/app/dist", ".erb/dll"]
}
Funny thing (not so much): Github action fails if running windows-latest
or ubuntu-latest
, but passes when running macos-latest
. I spent 2 days trying to reproduce locally, or fixing it without success. I just enabled tests only on macos-latest, until there is another workaround (or new ideas).
Having the same issue but with snapshot testing. Local runs fine, but when running in -ci mode, jest couldn't find the snapshot file it seems...
Version
28.0
Steps to reproduce
Run on Github Actions error: Unable to process '/home/runner/work/arch3.js/arch3.js/packages/arch3-core/src/archwayclient.ts', please make sure that
outDir
in your tsconfig is neither''
or'.'
. You can also configure Jest config optiontransformIgnorePatterns
to informts-jest
to transform /home/runner/work/arch3.js/arch3.js/packages/arch3-core/src/archwayclient.tsat TsCompiler.getCompiledOutput (../../node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js:165:27) at TsJestCompiler.getCompiledOutput (../../node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js:13:39) at TsJestTransformer.processWithTs (../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.js:232:37) at TsJestTransformer.process (../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.js:161:24) at ScriptTransformer.transformSource (../../node_modules/@jest/transform/build/ScriptTransformer.js:619:31) at ScriptTransformer._transformAndBuildScript (../../node_modules/@jest/transform/build/ScriptTransformer.js:765:40) at ScriptTransformer.transform (../../node_modules/@jest/transform/build/ScriptTransformer.js:822:19)
Expected behavior
Should run to completion like it does on local machine.
Actual behavior
Fails saying it cannot process a typescript file. It would help to know what the precise failure in processing the typescript file is. My outDir is set (again it works locally)
Debug log
11s Run yarn test:core FAIL src/archwayclient-rewards.spec.ts ● Test suite failed to run
FAIL src/archwayclient.spec.ts ● Test suite failed to run
Test Suites: 2 failed, 2 total Tests: 0 total Snapshots: 0 total Time: 5.769 s Ran all test suites. Error: Process completed with exit code 1.
Additional context
Github runner is ubuntu latest
Environment