Jest: Remove or extract binary script from `jest-runtime`

Created on 9 May 2020  路  6Comments  路  Source: facebook/jest

From #9712.

https://github.com/facebook/jest/tree/c6e63f331b491082075aef4c48ced355ae72add5/packages/jest-runtime/src/cli

We can either just remove it (I'm not really sure about the use case for it, it was added in #1193) or at least extract it out into its own package.

Help Wanted

All 6 comments

I started to work on this. The CLI of jest-runtime is used by jest-repl. What's the best option? Create a dedicated module (jest-runtme-cli?) or just move the code into jest-repl?

I think moving it into jest-repl makes sense - to the degree jest-repl is useful I think it's the only valid consumer of the CLI interface of the runtime. If somebody then ends up missing it as a standalone thing, we can extract it at that point

@SimenB jest-runtime still needs jest-config for its tests:
https://github.com/facebook/jest/blob/0e0eeed9d794fe0d6d7e84f555d9684f9e944221/packages/jest-runtime/src/__mocks__/createRuntime.js#L14-L36

I dont know how we could fix that.

Test should use https://github.com/facebook/jest/blob/master/TestUtils.ts instead of normalize

Some tests have settings like this:

const moduleNameMapper = {
  mappedToDirectory: '<rootDir>/MyDirectoryModule',
}

The <rootDir> is converted by jest-config. Should i also copy the helper method into TestUtils.ts? Or change the mapping to use an path.join. On one hand we duplicate some code, on the other hand we dont use the jest feature...

As createRuntime set the rootDir option; i think this function should also converts the mapper paths.

Was this page helpful?
0 / 5 - 0 ratings