feat: requires ts-node to start a project for any config that uses ts or jsx

This commit is contained in:
James
2023-01-10 11:48:40 -05:00
parent 96002dbda5
commit f1c342e05e
7 changed files with 29 additions and 76 deletions

View File

@@ -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');

View File

@@ -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(),