Skip to content

Conversation

@ChristophWurst
Copy link
Contributor

https://jestjs.io/docs/configuration#testenvironment-string

Tests can't be run otherwise.

 FAIL  test/scopedstorage.test.js
  ● ScopedStorage › sets an item

    The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string.
    Consider using the "jsdom" test environment.
    
    ReferenceError: window is not defined

      10 |
      11 |     beforeEach(() => {
    > 12 |         wrapped = window.localStorage
         |         ^
      13 |         storage = new ScopedStorage('test', wrapped, false)
      14 |     })
      15 |

      at Object.<anonymous> (test/scopedstorage.test.js:12:9)

@ChristophWurst ChristophWurst added the 3. to review Waiting for reviews label Oct 24, 2022
@ChristophWurst ChristophWurst self-assigned this Oct 24, 2022
@ChristophWurst ChristophWurst changed the title Fix test environment Fix test requiring a js dom environment Oct 24, 2022
@ChristophWurst ChristophWurst changed the title Fix test requiring a js dom environment Fix tests requiring a js dom environment Oct 24, 2022
Copy link

@tcitworld tcitworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since every test uses this, you might as well add some jest config file with testEnvironment: 'jsdom' instead?

Signed-off-by: Christoph Wurst <[email protected]>
@ChristophWurst ChristophWurst force-pushed the chore/fix-test-environment branch from 4c7cde3 to 7993e2f Compare October 24, 2022 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants