@angular-builders/jest Option "setupFilesAfterEnv" must be of type: array but instead received: object
Describe the Bug
Using @angular-builders/jest in angular.json to implement ng test
Minimal Reproduction
jest.config.js
`const { pathsToModuleNameMapper } = require('ts-jest'); const { compilerOptions: { paths: tsconfigPaths }, } = require('./tsconfig.base'); require('jest-preset-angular/ngcc-jest-processor');
const testMatch = '**/(.)@(spec|test).[tj]s?(x)';
const baseConfig = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: [<rootDir>/test-setup.ts],
globalSetup: 'jest-preset-angular/global-setup',
testMatch: [testMatch],
testPathIgnorePatterns: [
'<rootDir>/coverage/',
'<rootDir>/dist/',
'<rootDir>/e2e/',
'<rootDir>/node_modules/',
'tsconfig.spec.ts',
],
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs'],
moduleNameMapper: pathsToModuleNameMapper(tsconfigPaths, {
prefix: '<rootDir>/',
}),
collectCoverage: true,
coverageReporters: ['html'],
setupFiles: [
'<rootDir>/setups/localstorage.ts',
'<rootDir>/setups/window.ts',
'fake-indexeddb/auto',
],
transformIgnorePatterns: ['node_modules/(?!.*\.mjs$)'],
forceExit: true,
};
module.exports = {
projects: [
{
...baseConfig,
displayName: 'iam',
testMatch: [<rootDir>/apps/iam/${testMatch}],
},
{
...baseConfig,
displayName: 'iam-connector',
testMatch: [<rootDir>/apps/iam-connector/${testMatch}],
},
{
...baseConfig,
displayName: 'iam-manager',
testMatch: [<rootDir>/apps/iam-manager/${testMatch}],
},
{
...baseConfig,
displayName: 'iam-login',
testMatch: [<rootDir>/apps/iam-login/${testMatch}],
},
{
...baseConfig,
displayName: 'libs',
testMatch: [<rootDir>/libs/${testMatch}],
},
],
};
`
angular.json
"test": { "builder": "@angular-builders/jest:run", "options": { "configPath": "jest.config.js", "runInBand": true, "detectOpenHandles": true, "forceExit": true } },
Expected Behavior
Should work as intended
Screenshots
`● Validation Error:
Option "setupFilesAfterEnv" must be of type: array but instead received: object
Example: { "setupFilesAfterEnv": [ "<rootDir>/testSetupFile.js" ] }
Configuration Documentation: https://jestjs.io/docs/configuration `
Environment
Libs
- @angular/core version: 13.2.5
- @angular-devkit/build-angular version: 13.2.5
- @angular-builders/jest version: 13.0.3
For Tooling issues:
- Node version: 16.14.0
- Platform: Ubuntu/ OSX
Others:
Additional Context
Add any other context about the problem here.
You don't need to define this whole config yourself (the preset, the setup files from the preset, mocks for localstorage etc.). The builder does it for you. Only add parts that you need for your specific project (like collectCoverage: true etc.). The test matching patterns per project and paths are also generated automatically by the builder.
In any case if your problem persists after you fix your config I'm gonna need a minimal reproduction repository in order to check it.
@RogierKonings are you able to provide a minimal reproducible example?
Note: this was required when opening an issue. Note: Our policy is that issues reported without a reproduction will be closed immediately and then reopened once a reproduction has been provided. Please respect the developers of this project by doing this. We give of our personal time to work on this project and would rather be spending our time fixing or enhancing the library than chasing down badly described or unreproducible issues. Please delete this note once you have read it.