nx
nx copied to clipboard
@nx/jest/plugin Option "displayName" must be of type issue
Current Behavior
created monorepor with expo preset:
npx create-nx-workspace@latest --preset=expo --appName=my-app
Node version: v20.10.0
trying to start app using following command:
nx run my-app:run-ios
Getting following error:
NX Unable to create nodes for apps/app-bp/jest.config.ts using plugin @nx/jest/plugin.
Inner Error: Error: ● Validation Error:
Option "displayName" must be of type:
array
but instead received:
string
Example:
{
"displayName": [
"test-config",
{
"color": "blue",
"name": "test-config"
}
]
}
Configuration Documentation:
https://jestjs.io/docs/configuration
Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
If the error persists, please run "nx reset".
Expected Behavior
should spinup the app
GitHub Repo
No response
Steps to Reproduce
- Node version: v20.10.0 OS Macos 14.3 Beta (23D5033f) M2
- npx create-nx-workspace@latest --preset=expo --appName=my-app
- nx run my-app:run-ios
Nx Report
NX Unable to create nodes for apps/app-bp/jest.config.ts using plugin @nx/jest/plugin.
Inner Error: Error: ● Validation Error:
Option "displayName" must be of type:
array
but instead received:
string
Example:
{
"displayName": [
"test-config",
{
"color": "blue",
"name": "test-config"
}
]
}
Configuration Documentation:
https://jestjs.io/docs/configuration
Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
If the error persists, please run "nx reset".
Failure Logs
NX Unable to create nodes for apps/app-bp/jest.config.ts using plugin @nx/jest/plugin.
Inner Error: Error: ● Validation Error:
Option "displayName" must be of type:
array
but instead received:
string
Example:
{
"displayName": [
"test-config",
{
"color": "blue",
"name": "test-config"
}
]
}
Configuration Documentation:
https://jestjs.io/docs/configuration
Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
If the error persists, please run "nx reset".
Package Manager Version
10.2.3
Operating System
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
No response
Using DisplayName
type will allow you to proceed.
declare type DisplayName = {
name: string;
color: typeof ForegroundColor;
};
declare type ForegroundColor =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
| 'grey'
| 'blackBright'
| 'redBright'
| 'greenBright'
| 'yellowBright'
| 'blueBright'
| 'magentaBright'
| 'cyanBright'
| 'whiteBright';
I'm also running into this issue. Changing displayName to an array as suggested changes to error to should be a string or an object. No matter what type I use, the error persists.
@vivex
Not sure why (cache of course) but, if you delete node_modules
& .nx
cache folder (then reinstall packages), that error may disappear for you too (as it did for me).
Ah, for heavens sake why we have this issue in the first place. I mean come on...
jest.config.ts
import type { Config } from 'jest';
/* eslint-disable */
export default {
displayName: 'backend',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{ tsconfig: '<rootDir>/tsconfig.spec.json' },
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/backend',
} satisfies Config;
And with this, you can see it clearly that displayName cannot be an array but rather an object or string. So what's with this suggestion and error?
It is really annoying and frustrating since it appears 5 out of 10 times for me which means that I cannot really rely and leverage Nx's full power by pipelining different commands, it really slows us down...
I'm suffering the same problem. It seems related to the cache because when you execute the nx reset command it fixes the problem.
@dario-rodriguez I just reset cache and solved it. This is really frustrating. Slowing me down because I am now not sure what is wrong.
@vivex Not sure why (cache of course) but, if you delete
node_modules
&.nx
cache folder (then reinstall packages), that error may disappear for you too (as it did for me).
It helped me!
"@nx/jest": "18.2.2", Your repository uses a higher version of Nx (18.2.2) than your global CLI version (17.0.2)
I encountered this issue with a single jest.config file, which consumed a significant amount of my time. Following the suggestions provided here, I proceeded to delete the node_modules, nx/cache, and performed an nx reset, among other actions. However, upon reinstalling dependencies, I now encounter this error across all jest.config files. Frustrating, to say the least. :/
This helped!
// displayName: 'whatever_project'
https://github.com/nrwl/nx/issues/22591#issuecomment-2028701651
Any updates here? Running into this same issue. I'm doing a react-native-expo/react-vite monorepo app for my company and this is a huge barrier to us fully adopting Nx right now.
Not sure if commenting out displayName
as the comment above suggests will have any unintended consequences.
This helped!
// displayName: 'whatever_project'
This doesn't work for me, I commented out displayName
, and deleted .nx/cache
. and it still throws the same error.
upgrading the global nx
install did solve the issue though.
It happened randomly for me but nx reset fixes it all the time
Very annoying issue which still persists in nx. When it will be fixed ?
"Fix" for me is to add an empty line to the file and save it, run the nx command again, and then revert the file again. nx reset
seems to mostly trigger the problem for me.
hey all!
This issue should have been fixed in Nx 19.0.0. Please update to that version, and you should be good to go.
If you still get this error after the update, please leave us a message and we'll take a look.
Thanks for fixing it. @leosvelperez
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.