TestSpecification
TestSpecification
클래스는 실행될 테스트 모듈과 해당 매개변수를 정의합니다.
테스트 프로젝트 내에서 createSpecification
메서드를 통해서만 스펙을 생성할 수 있습니다.
const specification = project.createSpecification(
resolve('./example.test.ts'),
[20, 40] // optional test lines
);
createSpecification
은 확인된 모듈 ID를 필요로 합니다. 파일의 자동 확인이나 파일 시스템 존재 여부 확인은 수행하지 않습니다.
taskId
테스트 모듈의 식별자입니다.
project
테스트 모듈이 속한 TestProject
를 참조합니다.
moduleId
Vite의 모듈 그래프에 있는 모듈 ID입니다. 일반적으로 posix 구분 기호를 사용하는 절대 파일 경로입니다.
'C:/Users/Documents/project/example.test.ts'; // ✅
'/Users/mac/project/example.test.ts'; // ✅
'C:\\Users\\Documents\\project\\example.test.ts'; // ❌
testModule
스펙과 연결된 TestModule
인스턴스입니다. 테스트가 아직 큐에 추가되지 않은 경우 undefined
입니다.
pool experimental
테스트 모듈이 실행될 pool
입니다.
DANGER
poolMatchGlob
및 typecheck.enabled
를 사용하여 단일 테스트 프로젝트에 여러 풀을 가질 수 있습니다. 이는 동일한 moduleId
를 가지지만 다른 pool
을 가진 여러 스펙을 가질 수 있음을 의미합니다. Vitest 4에서는 프로젝트가 단일 풀만 지원하며 이 속성은 제거될 예정입니다.
testLines
이 필드는 createSpecification
메서드가 배열을 받은 경우에만 정의되며, 테스트 파일 내에서 테스트가 정의된 소스 코드의 라인 배열입니다.
적어도 한 줄에 테스트가 없으면 전체 스위트가 실패합니다. 올바른 testLines
구성 예시:
const specification = project.createSpecification(
resolve('./example.test.ts'),
[3, 8, 9]
);
import { test, describe } from 'vitest'
test('verification works')
describe('a group of tests', () => {
// ...
test('nested test')
test.skip('skipped test')
})
toJSON
function toJSON(): SerializedTestSpecification;