docs: update test and jest docs
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -444,8 +444,9 @@ working directory to the package that the test is in.
|
||||
|
||||
Where small customizations are needed, such as setting coverage thresholds or
|
||||
support for specific transforms, it is possible to override the Jest
|
||||
configuration through the `"jest"` field in `package.json`. These overrides will
|
||||
be loaded in from all `package.json` files in the directory ancestry, meaning
|
||||
configuration through the `"jest"` field in `package.json`. For a full list of
|
||||
options, see the [Jest documentation](https://jestjs.io/docs/en/configuration).
|
||||
These overrides will be loaded in from all `package.json` files in the directory ancestry, meaning
|
||||
that you can place common configuration in the `package.json` at the root of a
|
||||
monorepo. If multiple overrides are found, they will be merged together with
|
||||
configuration further down in the directory tree taking precedence.
|
||||
@@ -464,6 +465,14 @@ The overrides in a single `package.json` may for example look like this:
|
||||
},
|
||||
```
|
||||
|
||||
If you want to configure editor integration for tests we recommend executing the bundled configuration directly with Jest, rather than running through the Yarn test script. For example, with the Jest extension for VS Code, the configuration would look like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"jest.jestCommandLine": "node_modules/.bin/jest --config node_modules/@backstage/cli/config/jest.js"
|
||||
}
|
||||
```
|
||||
|
||||
## Publishing
|
||||
|
||||
Package publishing is an optional part of the Backstage build system and not
|
||||
|
||||
@@ -440,22 +440,7 @@ a yarn workspaces monorepo by automatically creating one grouped configuration
|
||||
that includes all packages that have `backstage-cli test` in their package
|
||||
`test` script.
|
||||
|
||||
If needed, the configuration can be extended using a `"jest"` field in
|
||||
`package.json`, both within the target package and the monorepo root, with
|
||||
configuration in the target package taking precedence. Refer to the
|
||||
[Jest configuration documentation](https://jestjs.io/docs/en/configuration) for
|
||||
a full list of configuration options.
|
||||
|
||||
In addition to the Jest configuration there's an optional `transformModules`
|
||||
option, which is an array of module names to include in transformations.
|
||||
Normally modules inside `node_modules` are not transformed, but there are cases
|
||||
were published packages are not transpiled far enough to be usable by Jest, in
|
||||
which case you need to enable transform of them.
|
||||
|
||||
Another way to override the Jest configuration is to place a `jest.config.js` or
|
||||
`jest.config.ts` file in the package root. As opposed to the `package.json` way
|
||||
of overriding config, this completely removes the base config, and so you need
|
||||
to set it up from scratch.
|
||||
For more information about configuration overrides and editor support, see the [Jest Configuration section](./cli-build-system.md#jest-configuration) in the build system documentation.
|
||||
|
||||
```text
|
||||
Usage: backstage-cli test [options]
|
||||
|
||||
Reference in New Issue
Block a user