We are running integration tests using jest and supertest inside a node js project that is being built with a DockerFile. This DockerFile is being run by a Kubernetes Job in an Azure Devops pipeline.
The problem is that the tests are not running for some reason, the step is just prompting for the command being executed, but nothing else.
Example output of the job logs:
`> [email protected] test:ci
cross-env ENVIRONMENT=cluster node -expose-gc ./node_modules/jest/bin/jest –runInBand
commandOutput
[email protected] test:ci
cross-env ENVIRONMENT=cluster node -expose-gc ./node_modules/jest/bin/jest –runInBand
`
As you can see, there is no trace of the tests being run. Locally, if I build the image and run it, it works perfectly and without any problem.
Dockerfile:
FROM node:18.18.0
ENV NODE_OPTIONS=--max_old_space_size=500
COPY ./ ./
RUN npm i
CMD [ "npm", "run", "test:ci" ]
jest.config.ts
import type { Config } from 'jest';
import { compilerOptions } from './tsconfig.json';
import { pathsToModuleNameMapper } from 'ts-jest';
const config: Config = {
coverageProvider: 'v8',
maxWorkers: 1,
workerIdleMemoryLimit: '500MB',
logHeapUsage: true,
verbose: false,
testRegex: '\.spec\.ts$',
preset: 'ts-jest',
setupFilesAfterEnv: ['<rootDir>/src/setup/env.setup.ts'],
globalTeardown: '<rootDir>/src/setup/teardown.setup.ts',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/src/'
})
};
export default config;
Package.json command:
"test:ci": "cross-env ENVIRONMENT=local node -expose-gc ./node_modules/jest/bin/jest --runInBand",
I am using the -expose-gc node to optimize the memory consumption of tests.
Any ideas? There is a specific configuration for jest and Azure pipelines?
I have tested several versions of nodeJS and jest to ensure compatibility, but I can never get the tests to run on CI.
Biel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.