mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[tests] Fix examples tests with shared util (#9415)
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
import { basename, join } from 'path';
|
||||
import { testDeployment } from '../../test/lib/deployment/test-deployment.js';
|
||||
import { lstatSync, readdirSync } from 'fs';
|
||||
|
||||
export async function deployExample(filename: string) {
|
||||
const { testDeployment } = require('../../test/lib/deployment/test-deployment.js');
|
||||
const example = basename(filename).replace(/\.test\.ts$/, '');
|
||||
await testDeployment(join(filename, '..', '..', '..', example));
|
||||
}
|
||||
|
||||
export function getExamples() {
|
||||
const dirname = join(__dirname, '..');
|
||||
const examples = readdirSync(dirname)
|
||||
.map(example =>
|
||||
({
|
||||
exampleName: example,
|
||||
examplePath: join(dirname, example),
|
||||
testPath: join(dirname, '__tests__', 'integration', `${example}.test.ts`),
|
||||
})
|
||||
)
|
||||
.filter(o =>
|
||||
!o.exampleName.startsWith('.') &&
|
||||
!o.exampleName.startsWith('_') &&
|
||||
o.exampleName !== 'node_modules' &&
|
||||
lstatSync(o.examplePath).isDirectory()
|
||||
);
|
||||
return examples;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user