test-runner
test-runner copied to clipboard
[bug] testMatch and `No tests found, exiting with code 1` on windows
Describe the bug
On windows, no tests will be found even when using the right testMatch patterns and having the right stories in place. Same repo with same config & tests is working on linux/mac, ie:
.storybook/main.js:
// https://github.com/storybookjs/storybook/issues/24013
export default {
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"],
staticDirs: ["../public"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/preset-create-react-app",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
features: {
emotionAlias: false,
},
core: {
builder: "@storybook/builder-vite"
},
docs: {
autodocs: false,
},
};
output:
>npm run test:storybook
> [email protected] test:storybook
> test-storybook --json --outputFile sb.json --url http://127.0.0.1:6006
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In D:\pkg
1900 files checked.
testMatch: d:/pkg/src/**/*.stories.@(js|jsx|ts|tsx) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 1900 matches
testRegex: - 0 matches
Pattern: - 0 matches
To Reproduce
I'm not sure, after some hours debugging this one I haven't found the right conditions & mcve to reproduce. I've tried using the same repository in long paths on windows, short paths and sometimes I've seen it globbing correctly but mostly of the time it won't. Of course, to make the test deterministic I've always removed node_modules (cache included) before trying to make sure test-storybook & jest run on a clean state.
Expected behavior
Jest should glob correctly no matter the type of windows paths your repo is living in.
System
Environment Info:
System: OS: Windows 10 10.0.19045 CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz Binaries: Node: 17.8.0 - C:\Program Files\nodejs\node.EXE npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.1266.0), Chromium (117.0.2045.43) npmPackages: @storybook/addon-actions: 7.4.5 => 7.4.5 @storybook/addon-essentials: 7.4.5 => 7.4.5 @storybook/addon-interactions: 7.4.5 => 7.4.5 @storybook/addon-links: 7.4.5 => 7.4.5 @storybook/builder-vite: ^7.4.5 => 7.4.5 @storybook/jest: 0.2.2 => 0.2.2 @storybook/node-logger: 7.4.5 => 7.4.5 @storybook/preset-create-react-app: 7.4.5 => 7.4.5 @storybook/react: 7.4.5 => 7.4.5 @storybook/react-webpack5: ^7.4.5 => 7.4.5 @storybook/test-runner: ^0.13.0 => 0.13.0 @storybook/testing-library: 0.2.1 => 0.2.1
Additional context
I've used yalc with test-runner to try to debug it with the exact version i'm using in production, e8ba6846c4e07a8d748c13ada64e1614374d2db1
v0.13.0 and after understanding the code I've got stuck at this line
I didn't see anything strange before kicking off jest. I've spent quite a lot of time on this one and I don't know how to proceed, tried to remove %userprofile%/npm-cache as well.... Funny thing, some of my colleagues using mac/unix not having this issue and other colleague with the same windows OS are not facing this one on specific paths. It seems for some reason jest is buggy and is not globbing properly on windows under certain circumstances (paths), but I don't know which ones are.
Hope you can advice how to proceed further.
Thanks in advance.
happens on linux CI as well
I've just tried with latest version of test-runner and this issue still happening,
"@storybook/test-runner": "0.16.0",
"@storybook/testing-library": "0.2.2",
ie:
d:\pkg>npm run test:storybook
> [email protected] test:storybook
> test-storybook --json --outputFile sb.json --url http://127.0.0.1:6006
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In d:\pkg
2314 files checked.
testMatch: d:/pkg/src/**/*.stories.@(js|jsx|ts|tsx) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 2314 matches
testRegex: - 0 matches
Pattern: - 0 matches
d:\pkg>find src -name "*.stories.jsx" | wc
195 195 15174
Linking https://github.com/jestjs/jest/issues/6509 as it may be relevant for this one