test(plugin-cloud): update jest config for esm

This commit is contained in:
Elliot DeNolf
2024-03-15 17:28:39 -04:00
parent eef06425a3
commit 09f2926bbb
3 changed files with 13 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"sourceMaps": true,
"exclude": ["/**/*.spec.ts", "/**/mocks"],
"exclude": ["/**/mocks"],
"jsc": {
"target": "esnext",
"parser": {

View File

@@ -1,15 +1,11 @@
module.exports = {
testEnvironment: 'node',
testMatch: ['**/src/**/*.spec.ts'],
transform: {
'^.+\\.(ts|tsx)?$': 'ts-jest',
},
verbose: true,
// globalSetup: './test/jest.setup.ts',
moduleNameMapper: {
'\\.(css|scss)$': '<rootDir>/src/webpack/mocks/emptyModule.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/src/webpack/mocks/fileMock.js',
},
testTimeout: 60000,
import baseConfig from '../../jest.config.js'
/** @type {import('@jest/types').Config} */
const customJestConfig = {
...baseConfig,
globalSetup: null,
testMatch: ['**/src/**/?(*.)+(spec|test|it-test).[tj]s?(x)'],
testTimeout: 20000,
}
export default customJestConfig

View File

@@ -8,7 +8,7 @@ import { payloadCloud } from './plugin.js'
describe('plugin', () => {
describe('not in Payload Cloud', () => {
// eslint-disable-next-line jest/expect-expect
it('should return unmodified config, with webpack aliases', () => {
it('should return unmodified config', () => {
const plugin = payloadCloud()
const config = plugin(createConfig())
@@ -119,26 +119,21 @@ describe('plugin', () => {
})
function assertCloudStorage(config: Config) {
expect(config.admin).toHaveProperty('webpack')
expect(config.upload?.useTempFiles).toEqual(true)
}
function assertNoCloudStorage(config: Config) {
expect(config.admin).toHaveProperty('webpack')
expect(config.upload?.useTempFiles).toBeFalsy()
}
function assertCloudEmail(config: Config) {
expect(config.admin).toHaveProperty('webpack')
if (config.email && 'transport' in config.email) {
expect(config.email?.transport?.transporter.name).toEqual('SMTP')
}
}
/** Asserts that plugin did not run (other than webpack aliases) */
/** Asserts that plugin did not run */
function assertNoCloudEmail(config: Config) {
expect(config.admin).toHaveProperty('webpack')
// No transport set
if (!config.email) return