capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.14k stars 189 forks source link

Attempting to change configurable attribute of unconfigurable property #1362

Closed PabloGracia closed 3 months ago

PabloGracia commented 4 months ago

Describe the bug I want to use RTL in bun, and according to the documentation in bun's page, it is advised to setup happy-dom for this purpose: https://bun.sh/docs/test/dom

I've followed the steps to the letter, but when running bun test I get the following error:

app/[...]/mytest.test.tsx:
35 |                             ...windowPropertyDescriptor,
36 |                             value: windowPropertyDescriptor.value.bind(global)
37 |                         });
38 |                     }
39 |                     else {
40 |                         Object.defineProperty(global, key, windowPropertyDescriptor);

TypeError: Attempting to change configurable attribute of unconfigurable property.
      at register (/[my_project_route]/node_modules/@happy-dom/global-registrator/lib/GlobalRegistrator.js:40:24)

To Reproduce Steps to reproduce the behavior:

  1. Go to https://bun.sh/docs/test/dom
  2. Set up the project according to the happy-dom specifications.
  3. Run bun test

Expected behavior The test runs without errors. From the error this seems to be on happy-dom side rather than on bun's, so I'm opening the issue here.

capricorn86 commented 3 months ago

Hi @PabloGracia! :slightly_smiling_face:

I have attempted to reproduce your problem without success. I have tested to follow the Bun guide and it worked for me.

There is a new fix in now that may solve your problem: https://github.com/capricorn86/happy-dom/releases/tag/v14.5.1

If it doesn't solve your problem, can you please provide with a reproducible example or a repository?

fabriziomarmitt commented 3 months ago

Hey @PabloGracia, I was having same issue, then I updated bun to version 1.1.2 and then it worked just fine.

capricorn86 commented 3 months ago

Based on the tests and answers, I will close this ticket.

Please re-open if it still isn't working for you @PabloGracia.