test-runner
test-runner copied to clipboard
[Bug] TypeError: Cannot read property 'toLowerCase' of undefined when running tests without title
Describe the bug
When I go to the official storybook page, it says here that title is optional https://storybook.js.org/docs/react/writing-stories/introduction#default-export However, if I don't put in the title, the test-runner fails
Steps to reproduce the behavior
-
Write a story without a title
-
Run pnpm test-storybook
-
See error ` Test suite failed to run
TypeError: Cannot read property 'toLowerCase' of undefined
at sanitize (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@storybook/csf/dist/index.js:51:17) at sanitizeSafe (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@storybook/csf/dist/index.js:58:19) at toId (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@storybook/csf/dist/index.js:72:20) at ../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@storybook/csf-tools/dist/cjs/CsfFile.js:499:34 at Array.reduce (
) at CsfFile.parse (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@storybook/csf-tools/dist/cjs/CsfFile.js:493:31) at transformCsf (../../common/temp/node_modules/.pnpm/@[email protected][email protected]/node_modules/@storybook/test-runner/dist/cjs/csf/transformCsf.js:68:7) at transformPlaywright (../../common/temp/node_modules/.pnpm/@[email protected][email protected]/node_modules/@storybook/test-runner/dist/cjs/playwright/transformPlaywright.js:76:49) at Object.process (../../common/temp/node_modules/.pnpm/@[email protected][email protected]/node_modules/@storybook/test-runner/playwright/transform.js:6:21) at ScriptTransformer.transformSource (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:619:31) at ScriptTransformer._transformAndBuildScript (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:765:40) at ScriptTransformer.transform (../../common/temp/node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:822:19)`
Expected behavior
The test should run successfully
Environment
- OS: Ubuntu
- Node.js version: v16.15.0
- NPM version: 6.14.13
Dependencies version
"devDependencies": {
"@babel/core": "^7.17.9",
"@storybook/addon-actions": "6.4.22",
"@storybook/addon-essentials": "6.4.22",
"@storybook/addon-interactions": "6.4.22",
"@storybook/addon-links": "6.4.22",
"@storybook/builder-vite": "^0.1.30",
"@storybook/react": "6.4.22",
"@storybook/testing-library": "0.0.11",
"@storybook/client-api": "6.4.22",
"@storybook/client-logger": "6.4.22",
"@storybook/addon-docs": "6.4.22",
"@storybook/addon-backgrounds": "6.4.22",
"@storybook/addon-measure": "6.4.22",
"@storybook/addon-outline": "6.4.22",
"storybook-addon-material-ui5": "1.0.0",
"@storybook/addon-a11y": "6.4.22",
"@storybook/jest": "0.0.10",
"@storybook/test-runner": "0.1.1",
"@storybook/addon-storyshots": "6.4.22",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/node": "17.0.35",
"jest": "27.5.1",
"ts-jest": "27.1.4",
"@types/jest": "^27.5.1",
"axe-playwright": "1.1.11",
"@vitejs/plugin-react": "^1.3.0",
"babel-loader": "^8.2.5",
"typescript": "^4.6.3",
"vite": "^2.9.5",
"@mdx-js/react": "^2.1.1"
}
Additional context
When I add the title everything works as expected.
So Is there anything I can do to not have the title and the tests would still run as normal?