mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-07 01:16:28 +02:00
Vitest Pros: * Automated failing test comments on github PRs * A nice local UI with incremental testing when changing files (`yarn test:ui`) * Also nicely supported in all major IDEs, click to run test works (so we won't miss what we had with jest). * Works well with ESM Vitest Cons: * The ESBuild transformer vitest uses takes a little longer to transform than our current SWC/jest setup, however, it is possible to setup SWC as the transformer for vitest as well (though it only does one transform, so we're paying ~7-10 seconds instead of ~ 2-3 seconds in transform phase). * Exposes how slow our tests are (tongue in cheek here)
31 lines
1008 B
TypeScript
31 lines
1008 B
TypeScript
import fc, { type Arbitrary } from 'fast-check';
|
|
import {
|
|
playgroundResponseSchema,
|
|
type PlaygroundResponseSchema,
|
|
} from '../../../lib/openapi/spec/playground-response-schema.js';
|
|
import { validateSchema } from '../validate.js';
|
|
import { generate as generateInput } from './playground-request-schema.test.js';
|
|
import { generate as generateFeature } from './playground-feature-schema.test.js';
|
|
import { test } from '@fast-check/vitest';
|
|
const generate = (): Arbitrary<PlaygroundResponseSchema> =>
|
|
fc.record({
|
|
input: generateInput(),
|
|
features: fc.uniqueArray(generateFeature(), {
|
|
selector: (feature) => feature.name,
|
|
}),
|
|
});
|
|
|
|
test(
|
|
'playgroundResponseSchema',
|
|
() =>
|
|
fc.assert(
|
|
fc.property(
|
|
generate(),
|
|
(data: PlaygroundResponseSchema) =>
|
|
validateSchema(playgroundResponseSchema.$id, data) ===
|
|
undefined,
|
|
),
|
|
),
|
|
{ timeout: 60000 },
|
|
);
|