Closed akz08 closed 2 years ago
Your project is using jest
to run its test with a custom wrapper around jest, backstage/cli
. Under the covers it generates a configuration file when you run tests using backstage test
but for other tools (like jest
cli, or like Wallaby) this configuration is hidden (https://github.com/backstage/backstage/blob/master/packages/cli/config/jest.js).
To get Wallaby working for your project, you will need to first configure jest
to run your tests using the CLI.
We reverse engineered what backstage/cli
is doing to do this for you. After you get jest
to run from the CLI, Wallaby will work for you.
You will need to create 3 new files:
module.exports = {
projects: [
'<rootDir>/packages/app',
'<rootDir>/packages/backend',
]
}
module.exports = {
rootDir: './src',
coverageDirectory: './coverage',
collectCoverageFrom: ['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts'],
moduleNameMapper: {
'\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'),
},
transform: {
'\\.esm\\.js$': require.resolve('@backstage/cli/config/jestEsmTransform.js'),
'\\.(js|jsx|ts|tsx)$': require.resolve('@sucrase/jest-plugin'),
'\\.(bmp|gif|jpg|jpeg|png|frag|xml|svg|eot|woff|woff2|ttf)$': require.resolve('@backstage/cli/config/jestFileTransform.js'),
'\\.(yaml)$': require.resolve('jest-transform-yaml'),
},
testMatch: ['**/?(*.)test.{js,jsx,mjs,ts,tsx}'],
transformIgnorePatterns: [
`/node_modules/(?!@asyncapi/react-component).*\\.(?:(?<!esm\\.)js|json)$`,
],
setupFilesAfterEnv: [
'<rootDir>/setupTests.ts'
]
}
module.exports = {
rootDir: './src',
coverageDirectory: './coverage',
collectCoverageFrom: ['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts'],
moduleNameMapper: {
'\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'),
},
transform: {
'\\.esm\\.js$': require.resolve('@backstage/cli/config/jestEsmTransform.js'),
'\\.(js|jsx|ts|tsx)$': require.resolve('@sucrase/jest-plugin'),
'\\.(bmp|gif|jpg|jpeg|png|frag|xml|svg|eot|woff|woff2|ttf)$': require.resolve('@backstage/cli/config/jestFileTransform.js'),
'\\.(yaml)$': require.resolve('jest-transform-yaml'),
},
testMatch: ['**/?(*.)test.{js,jsx,mjs,ts,tsx}'],
transformIgnorePatterns: [
`/node_modules/(?!@asyncapi/react-component).*\\.(?:(?<!esm\\.)js|json)$`,
],
}
That worked for my setup with minimal fiddling - thanks!
Issue description or question
Hi, I'm trying to get Wallaby running on an open source monorepo sample project: Backstage and I'm sort of struggling to figure out why it's stumbling upon itself. Any ideas on what I might need to do with my
wallaby.js
config?I've attached the diagnostics report with the project as-is, but I seem to have gotten somewhere when I added a
babel.config.js
withFor some reason when I put in those presets in a wallaby.js file it wasn't working.
Unfortunately that still hasn't gotten me anywhere usable just yet anyway, so I may be barking up the wrong tree... Thanks!
Wallaby diagnostics report