-
Notifications
You must be signed in to change notification settings - Fork 454
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
Babel support is broken in 26.4.2 #2064
Comments
At the very least, Babel configuration should be loaded from the same directory as the Jest configuration. It appears /// @file lightning-banana/packages/common/jest.config.json
{
"globals": {
"ts-jest": {
/// Resolved to "lightning-banana/.babelrc"
/// Expected to resolve to "lightning-banana/packages/common/.babelrc"
"babelConfig": "<rootDir>/.babelrc"
}
},
"roots": [
/// Resolved to "lightning-banana/packages/common/src"
"<rootDir>/src"
],
"setupFilesAfterEnv": [
/// Resolved to "lightning-banana/packages/common/jest.setup.js"
"<rootDir>/jest.setup.js"
]
} ts-jest/src/config/config-set.ts Line 220 in a93fff1
|
indeed confirmed 26.4.1 works with this |
/cc @ahnpnl There still seems to be an issue with loading Babel-related files. Setting |
@RA80533 I checked the codes in 26.4.1 and that is also the case. When
after that |
I've isolated the issue to my use of Yarn workspaces:
To be clear, the parent directory does not contain any Babel-related files whereas @ahnpnl I suppose this isn't a regression issue then. |
/cc @ahnpnl Prior to its change in commit a0e5639 (see lines 186–195 of config-set.ts), Babel configuration was handled correctly in commit dee15ff (see lines 264–265 of config-set.ts): // babel config (for babel-jest) default is undefined so we don't need to have fallback like tsConfig or packageJson
const babelConfig: TsJestConfig['babelConfig'] = this.getInlineOrFileConfigOpt(options.babelConfig) /**
* @internal
*/
private getInlineOrFileConfigOpt(
configOpt: string | boolean | Record<string, any> | undefined,
): { kind: 'inline' | 'file'; value: any } | undefined {
if (typeof configOpt === 'string' || configOpt === true) {
return {
kind: 'file',
value: typeof configOpt === 'string' ? this.resolvePath(configOpt) : undefined,
}
} else if (typeof configOpt === 'object') {
return {
kind: 'inline',
value: configOpt,
}
}
return
} resolvePath(
inputPath: string,
{ throwIfMissing = true, nodeResolve = false }: { throwIfMissing?: boolean; nodeResolve?: boolean } = {},
): string {
let path: string = inputPath
let nodeResolved = false
if (path.startsWith('<rootDir>')) {
path = resolve(join(this._rootDir, path.substr(9)))
} else if (!isAbsolute(path)) {
if (!path.startsWith('.') && nodeResolve) {
try {
path = require.resolve(path)
nodeResolved = true
} catch (_) {}
}
if (!nodeResolved) {
path = resolve(this.cwd, path)
}
}
if (!nodeResolved && nodeResolve) {
try {
path = require.resolve(path)
nodeResolved = true
} catch (_) {}
}
if (throwIfMissing && !existsSync(path)) {
throw new Error(interpolate(Errors.FileNotFound, { inputPath, resolvedPath: path }))
}
this.logger.debug({ fromPath: inputPath, toPath: path }, 'resolved path from', inputPath, 'to', path)
return path
} |
In the scenario of
which is then go to this https://github.com/kulshekhar/ts-jest/blob/v26.4.1/src/config/config-set.ts#L378 . Because
and for the refactored codes, the scenario So both old codes and refactored codes are the same. |
💥 Regression Report
PR #2020 introduced a breaking change related to how Babel configuration is loaded. Previously, Babel configuration was loaded via the
babelConfig
option.Last working version
Worked up to version: 26.4.1
Stopped working in version: 26.4.2
To Reproduce
Steps to reproduce the behavior:
rootDir
as the root directory of the projectExpected behavior
babelConfig
should be read.The text was updated successfully, but these errors were encountered: