Files
vercel/packages/fs-detectors/test/unit.examples.test.ts
Nathan Rajlich 42c0b32a8d [fs-detectors] Use LocalFileSystemDetector instead of FixtureFilesystem (#10100)
The code for these two are almost identical, so consolidate into one codebase.

Also adjusts the `pnpm test` script to allow for specifying a file name to be executed, instead of running all tests.
2023-06-13 23:30:00 +00:00

25 lines
849 B
TypeScript
Vendored

import frameworkList from '@vercel/frameworks';
import { detectFramework, LocalFileSystemDetector } from '../src';
import { getExamples } from '../../../examples/__tests__/test-utils';
describe('examples should be detected', () => {
it.each(getExamples())(
'should detect $exampleName',
async ({ exampleName, examplePath }) => {
const fs = new LocalFileSystemDetector(examplePath);
const framework = await detectFramework({ fs, frameworkList });
if (!framework) {
throw new Error(`Framework not detected for example "${exampleName}".`);
}
if (exampleName === 'storybook') {
// Storybook isn't really a "framework", in this case, it's really a
// Next.js app
expect(framework).toBe('nextjs');
} else {
expect(framework).toBe(exampleName);
}
}
);
});