-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cannot read properties of undefined (reading 'location') #22142
Comments
@Muhammad-Magomedov please mock the location |
Storyshots executes in node, so |
I'm getting this same error after upgrading many packages. I thought I'd worked around it by setting the test environment to If mocking is required, could that be mentioned here? Possibly it's worth clarifying that it's not a crash in my code, or with any particular story, but that it happens within the call to
I'm on storybook 7.0.21, jest 29.5.0, puppeteer 20.7.2, and vite 4.3.2. |
I can bypass the above error by running the following in
But that just brings me to an error in
|
@FTWinston > I can bypass the above error by running the following in
Just pass the condition there,as it is undefined |
Sorry, I don't follow. This isn't in my code, it's still within the call to |
I get this error on a new vite repo, running storyshots against storybook 7.0.24. I've attached a reproduction: I also made an attempt at a stackblitz reproduction, though that hits a stack overflow rather than the above error. Please advise on any additional configuration that may be required to get |
I get the same Storybook 7.0.25 against Next.js. Also OP please edit the title to include StoryShots |
This comment suggests that Storyshots won't get any further updates. As it doesn't currently run, this potentially means it isn't actually currently supported, and that the docs "just" need updated to state this? |
The Storyshots addon is officially deprecated and will be removed in a future release of Storybook. To help with the transition process, we've created a migration guide for the available options and common use cases. |
UPDATE in 21.12.2023Resolved it, you can find more info here Original commentFor me it is happening with this import type { StorybookConfig } from '@storybook/nextjs';
import path from 'path';
export default {
stories: [
'../app/**/*.mdx',
'../libs/**/*.mdx',
'../app/**/*.stories.@(js|jsx|mjs|ts|tsx)',
'../libs/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
'@storybook/jest',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-onboarding',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/nextjs',
options: {
nextConfigPath: path.resolve(
__dirname,
'../next.config.js',
),
},
},
docs: {
autodocs: 'tag',
},
typescript: {
check: true,
skipCompiler: false,
},
} satisfies StorybookConfig; and here is my import type { Preview } from '@storybook/react';
export default {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
} satisfies Preview; and here is my <script>
document.cookie = 'access_token=' + 'jwtToken';
</script> But I am still getting this error msg: pnpm storybook
> my-project@0.1.0 storybook /Users/kasir.barati/projects/nextjs-playground
> storybook dev -p 6006
@storybook/cli v7.6.3
TypeError: Cannot read properties of undefined (reading 'location')
at instrument (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/@storybook+jest@0.2.3_jest@29.7.0/node_modules/@storybook/jest/dist/index.js:385:38)
at Object.<anonymous> (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/@storybook+jest@0.2.3_jest@29.7.0/node_modules/@storybook/jest/dist/index.js:392:121)
at Module._compile (node:internal/modules/cjs/loader:1257:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
at Object.newLoader (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.18.20/node_modules/esbuild-register/dist/node.js:2262:9)
at extensions..js (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.18.20/node_modules/esbuild-register/dist/node.js:4838:24)
at Module.load (node:internal/modules/cjs/loader:1115:32)
at Module._load (node:internal/modules/cjs/loader:962:12)
at Module.require (node:internal/modules/cjs/loader:1139:19)
at require (node:internal/modules/helpers:121:18)
TypeError: Cannot read properties of undefined (reading 'location')
at instrument (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/@storybook+jest@0.2.3_jest@29.7.0/node_modules/@storybook/jest/dist/index.js:385:38)
at Object.<anonymous> (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/@storybook+jest@0.2.3_jest@29.7.0/node_modules/@storybook/jest/dist/index.js:392:158)
at Module._compile (node:internal/modules/cjs/loader:1257:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
at Object.newLoader (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.18.20/node_modules/esbuild-register/dist/node.js:2262:9)
at extensions..js (/Users/kasir.barati/projects/nextjs-playground/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.18.20/node_modules/esbuild-register/dist/node.js:4838:24)
at Module.load (node:internal/modules/cjs/loader:1115:32)
at Module._load (node:internal/modules/cjs/loader:962:12)
at Module.require (node:internal/modules/cjs/loader:1139:19)
at require (node:internal/modules/helpers:121:18)
info => Starting manager..
WARN No story files found for the specified pattern: app/**/*.mdx
WARN No story files found for the specified pattern: libs/**/*.mdx
info => Starting preview..
info Using Babel compiler
info Addon-docs: using MDX2
info => Using implicit CSS loaders
info => Using default Webpack5 setup
<i> [webpack-dev-middleware] wait until bundle finished
<i> [webpack-dev-middleware] wait until bundle finished: /mockServiceWorker.js
╭─────────────────────────────────────────────────────╮
│ │
│ Storybook 7.6.3 for nextjs started │
│ 273 ms for manager and 5.34 s for preview │
│ │
│ Local: http://localhost:6006/ │
│ On your network: http://192.168.178.49:6006/ │
│ │
╰─────────────────────────────────────────────────────╯
No errors found.
No errors found. Any idea? I do not have storyshot but why is this error still occuring? |
Why don't mock the location ? it will fix it. |
@Chandan9898Kumar I updated my original comment. Read it again. It has been resolved |
Describe the bug
I installed storyshots and followed the instructions in the documentation, but when running the npm test script (test:jest), I'm getting the error
"TypeError: Cannot read properties of undefined (reading 'location')."
To Reproduce
No response
System
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: