Add option for source maps when running tests (#24577)

I added a `--sourceMaps` option to our test command that enables inline
source maps. I've kept it disabled by default, since it makes the tests
run slower. But it's super useful when attaching to a debugger.
This commit is contained in:
Andrew Clark
2022-05-18 13:48:21 -04:00
committed by GitHub
parent 0918e10203
commit e25a98b8a6
2 changed files with 15 additions and 0 deletions
+12
View File
@@ -110,6 +110,12 @@ const argv = yargs
requiresArg: true,
type: 'string',
},
sourceMaps: {
describe:
'Enable inline source maps when tranforming source files with Jest. Useful for debugging, but makes it slower.',
type: 'boolean',
default: false,
},
}).argv;
function logError(message) {
@@ -333,6 +339,12 @@ function getEnvars() {
envars.REACT_VERSION = semver.coerce(argv.reactVersion);
}
if (argv.sourceMaps) {
// This is off by default because it slows down the test runner, but it's
// super useful when running the debugger.
envars.JEST_ENABLE_SOURCE_MAPS = 'inline';
}
return envars;
}
+3
View File
@@ -93,6 +93,9 @@ module.exports = {
babelOptions,
{
plugins,
sourceMaps: process.env.JEST_ENABLE_SOURCE_MAPS
? process.env.JEST_ENABLE_SOURCE_MAPS
: false,
}
)
);