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

Test suite failed to run: TypeError: Attempted to assign to readonly property #17986

Open
Electroid opened this issue Mar 7, 2025 · 0 comments
Labels
ecosystem Something that relates to package or framework compatibility

Comments

@Electroid
Copy link
Contributor

Reproduction

  1. Clone tough-cookie
  2. Run bun install & bun --bun run test (this runs Jest using Bun)
  3. See output
 FAIL  __tests__/cookiePrefixes.spec.ts
   Test suite failed to run

    TypeError: Attempted to assign to readonly property.

      at ../node_modules/jest-runtime/build/index.js:1638:6
      at forEach (native)
      at Object.<anonymous> (../node_modules/stack-utils/index.js:10:9)
      at Object.<anonymous> (../node_modules/expect/build/toThrowMatchers.js:9:30)
      at Object.<anonymous> (../node_modules/expect/build/index.js:23:54)
      at _expect (../node_modules/@jest/expect/build/index.js:8:22)
      at createJestExpect (../node_modules/@jest/expect/build/index.js:29:9)

And looks like the issue is here:

    // should we implement the class ourselves?
    class Module extends _module().default.Module {}
    Object.entries(_module().default.Module).forEach(([key, value]) => {
      // @ts-expect-error: no index signature
      Module[key] = value; // <--------
    });
    Module.Module = Module;
    if ('createRequire' in _module().default) {
      Module.createRequire = createRequire;
    }
@RiskyMH RiskyMH added the ecosystem Something that relates to package or framework compatibility label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem Something that relates to package or framework compatibility
Projects
None yet
Development

No branches or pull requests

2 participants