chore: jest esm compat
This commit is contained in:
@@ -6,11 +6,13 @@
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
const customJestConfig = {
|
const customJestConfig = {
|
||||||
|
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||||
globalSetup: './test/jest.setup.ts',
|
globalSetup: './test/jest.setup.ts',
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\.(css|scss)$': '<rootDir>/packages/payload/src/bundlers/mocks/emptyModule.js',
|
'\\.(css|scss)$': '<rootDir>/test/helpers/mocks/emptyModule.js',
|
||||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
||||||
'<rootDir>/packages/payload/src/bundlers/mocks/fileMock.js',
|
'<rootDir>/test/helpers/mocks/fileMock.js',
|
||||||
|
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||||||
},
|
},
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['<rootDir>/packages/payload/src/**/*.spec.ts', '<rootDir>/test/**/*int.spec.ts'],
|
testMatch: ['<rootDir>/packages/payload/src/**/*.spec.ts', '<rootDir>/test/**/*int.spec.ts'],
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { Payload } from '../../packages/payload/src'
|
import type { Payload } from '../../packages/payload/src/index.js'
|
||||||
|
|
||||||
import { getPayload } from '../../packages/payload/src'
|
import { getPayload } from '../../packages/payload/src/index.js'
|
||||||
import { devUser } from '../credentials'
|
import { devUser } from '../credentials.js'
|
||||||
import { NextRESTClient } from '../helpers/NextRESTClient'
|
import { NextRESTClient } from '../helpers/NextRESTClient.js'
|
||||||
import { postsSlug } from './collections/Posts'
|
import { postsSlug } from './collections/Posts/index.js'
|
||||||
import configPromise from './config'
|
import configPromise from './config.js'
|
||||||
|
|
||||||
let payload: Payload
|
let payload: Payload
|
||||||
let token: string
|
let token: string
|
||||||
|
|||||||
1
test/helpers/mocks/emptyModule.js
Normal file
1
test/helpers/mocks/emptyModule.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export default () => {}
|
||||||
1
test/helpers/mocks/fileMock.js
Normal file
1
test/helpers/mocks/fileMock.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export default 'file-stub'
|
||||||
Reference in New Issue
Block a user