Runs additional integration tests for the library, returning a Promise indicating whether the test run succeeded or failed.
NOTE:
integrate()assumes the integration tests live within theintegration-tests/srcfolder of the current working directory where the script is being called.
The integration tests generally are run in your continuous integration (CI) environment to verify that your library when packaged can successfully be used by clients. The goal is dummy library/project in which you write tests that import and use the library like a normal client would.
The integration test process is as follows:
npm packthe built library to create the same.tgztarball that would be published in the registry- Copy the integration tests "project" at
integration-tests/over to a temporary directory npm installthe packed library (from Step 1),@benmvp/cli, and any other dependencies specified in thepackage.jsonof the project- Run
npx benmvp teston the project to use@benmvp/clito run the tests
Looking for CLI docs? View companion benmvp integrate documentation.
To run all modes of integration tests on all files (default behavior):
import { integrate } from '@benmvp/cli'
integrate()To run just the integration tests themselves (excluding linting & typing) on all files:
import { integrate } from '@benmvp/cli'
integrate({
modes: ['spec'],
})To run just linting & typing on all files in the integration tests project:
import { integrate } from '@benmvp/cli'
integrate({
modes: ['lint', 'type'],
})To run all modes only on files within utils/ directories of the integration tests project:
import { integrate } from '@benmvp/cli'
integrate({
pattern: 'utils/',
})To just run linting on files within api/ directories of the integration tests project:
import { integrate } from '@benmvp/cli'
integrate({
modes: ['lint'],
pattern: 'api/',
})integrate() has the following TypeScript signature:
type Mode = 'spec' | 'type' | 'lint'
namespace TestOptions {
modes: Mode[];
pattern: string;
}
(options?: TestOptions): Promise<Result>The optional TestOptions object supports the following properties:
An Array of the types or modes of tests to run. Available modes:
'spec'- Runs Jest-based tests (files ending in.spec.tsor in__tests__folder)'type'- Runs Typescript type-checking (files ending in.tsor.tsx)'lint'- Runs ESLint (files ending in.tsor.tsx)
Optional. Defaults to all modes when unspecified.
A regexp pattern string that is matched against all tests paths before executing the test.
Optional. Defaults to '' (signifying no filter)
integrate() returns a Promise.
When integrate() finishes successfully, the resolved value will be an object with a code property set to 0.
If integrate() exits unsuccessfully, the resolved value will be an object with a non-zero code property, a user-friendly message property, and an error property pointing to the inner exception.
Looking for CLI docs? View companion benmvp integrate documentation.
Still unsure of how to use @benmvp/cli? Ask for help!