diff options
-rw-r--r-- | jest.config.js | 2 | ||||
-rw-r--r-- | setupTests.js | 22 | ||||
-rw-r--r-- | vnext/server/middleware/android.spec.js | 4 | ||||
-rw-r--r-- | vnext/server/middleware/mastodon.spec.js | 4 | ||||
-rw-r--r-- | vnext/server/middleware/webfinger.spec.js | 4 |
5 files changed, 25 insertions, 11 deletions
diff --git a/jest.config.js b/jest.config.js index 69b061e1..abaffdbd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,6 +8,6 @@ module.exports = { '^.+\\.js$': '@swc/jest' }, transformIgnorePatterns: ['!node_modules/'], - testEnvironment: 'node', + testEnvironment: 'jsdom', setupFilesAfterEnv: ['<rootDir>/setupTests.js'] } diff --git a/setupTests.js b/setupTests.js index 1b4e29f8..7658559c 100644 --- a/setupTests.js +++ b/setupTests.js @@ -1,14 +1,16 @@ import '@testing-library/jest-dom' -window.matchMedia = window.matchMedia || function() { - return { - matches: true, - media: '', - addListener: function() { return true }, - removeListener: function() { return true }, - addEventListener: function() { return true }, - removeEventListener: function() { return true }, - dispatchEvent: function() { return true }, - onchange: function() { return true } +if (typeof window !== 'undefined') { + window.matchMedia = window.matchMedia || function() { + return { + matches: true, + media: '', + addListener: function() { return true }, + removeListener: function() { return true }, + addEventListener: function() { return true }, + removeEventListener: function() { return true }, + dispatchEvent: function() { return true }, + onchange: function() { return true } + } } } diff --git a/vnext/server/middleware/android.spec.js b/vnext/server/middleware/android.spec.js index 19d380d7..f5b9792a 100644 --- a/vnext/server/middleware/android.spec.js +++ b/vnext/server/middleware/android.spec.js @@ -1,3 +1,7 @@ +/** + * @jest-environment node + */ + import request from 'supertest' import { app } from '../app' diff --git a/vnext/server/middleware/mastodon.spec.js b/vnext/server/middleware/mastodon.spec.js index 561303bc..7f30d027 100644 --- a/vnext/server/middleware/mastodon.spec.js +++ b/vnext/server/middleware/mastodon.spec.js @@ -1,3 +1,7 @@ +/** + * @jest-environment node + */ + import request from 'supertest' import { app } from '../app' diff --git a/vnext/server/middleware/webfinger.spec.js b/vnext/server/middleware/webfinger.spec.js index d1b198e6..c36c4571 100644 --- a/vnext/server/middleware/webfinger.spec.js +++ b/vnext/server/middleware/webfinger.spec.js @@ -1,3 +1,7 @@ +/** + * @jest-environment node + */ + import request from 'supertest' import { app } from '../app' |