Skip to content
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

Fix goober running in vitest #589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hpinkos
Copy link

@hpinkos hpinkos commented Aug 29, 2024

Prevents an error when importing a component using goober into a vitest unit test

TypeError: Cannot add property p, object is not extensible
 ❯ a node_modules/goober/dist/goober.modern.js:1:2084

The error is happening because this is equivalent to module.exports

console.log(this);

[Module: null prototype] {
  css: [Function: u],
  extractCss: [Function: r],
  glob: [Function: bound u],
  keyframes: [Function: bound u],
  setup: [Function: m],
  styled: [Function: j]
}

Reproducible example of the error: https://github.com/hpinkos/vitest-goober

Copy link

vercel bot commented Aug 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
goober-rocks ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2024 3:18pm

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@cristianbote
Copy link
Owner

heya @hpinkos thanks for looking into this. Adding that check adds 17B and wondering if this #562 could also fix what you are seeing but with a smaller footprint?

@hpinkos
Copy link
Author

hpinkos commented Aug 29, 2024

@cristianbote unfortunately no. I did check that out and try it first, but in this environment globalThis is set up to be a mocked version of window so it's not equivalent to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants