feat: requires ts-node to start a project for any config that uses ts or jsx
This commit is contained in:
36
test/dev.js
36
test/dev.js
@@ -1,36 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const swcRegister = require('@swc/register');
|
||||
|
||||
const [testSuiteDir] = process.argv.slice(2);
|
||||
|
||||
if (!testSuiteDir) {
|
||||
console.error('ERROR: You must provide an argument for "testSuiteDir"');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts');
|
||||
|
||||
if (!fs.existsSync(configPath)) {
|
||||
console.error('ERROR: You must pass a valid directory under test/ that contains a config.ts');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.env.PAYLOAD_CONFIG_PATH = configPath;
|
||||
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true';
|
||||
|
||||
swcRegister({
|
||||
sourceMaps: 'inline',
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
tsx: true,
|
||||
},
|
||||
},
|
||||
module: {
|
||||
type: 'commonjs',
|
||||
},
|
||||
});
|
||||
|
||||
require('./devServer');
|
||||
@@ -1,9 +1,29 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import express from 'express';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import payload from '../src';
|
||||
|
||||
const [testSuiteDir] = process.argv.slice(2);
|
||||
|
||||
if (!testSuiteDir) {
|
||||
console.error('ERROR: You must provide an argument for "testSuiteDir"');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts');
|
||||
|
||||
if (!fs.existsSync(configPath)) {
|
||||
console.error('ERROR: You must pass a valid directory under test/ that contains a config.ts');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.env.PAYLOAD_CONFIG_PATH = configPath;
|
||||
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true';
|
||||
|
||||
const expressApp = express();
|
||||
|
||||
const init = async () => {
|
||||
await payload.init({
|
||||
secret: uuid(),
|
||||
Reference in New Issue
Block a user