@@ -2,24 +2,30 @@ import type { ParserOptions } from '@typescript-eslint/types';
22
33import * as scopeManager from '@typescript-eslint/scope-manager' ;
44import * as typescriptESTree from '@typescript-eslint/typescript-estree' ;
5- import path from 'node:path' ;
65import { ScriptTarget } from 'typescript' ;
76
8- import { parse , parseForESLint } from '../../src/parser' ;
7+ import { parse , parseForESLint } from '../../src/parser.js' ;
8+ import { FIXTURES_DIR } from '../test-utils/test-utils.js' ;
99
1010describe ( 'parser' , ( ) => {
11- beforeEach ( ( ) => {
11+ afterEach ( ( ) => {
1212 vi . clearAllMocks ( ) ;
1313 } ) ;
1414
15+ afterAll ( ( ) => {
16+ vi . restoreAllMocks ( ) ;
17+ } ) ;
18+
1519 it ( 'parse() should return just the AST from parseForESLint()' , ( ) => {
1620 const code = 'const valid = true;' ;
17- expect ( parse ( code ) ) . toEqual ( parseForESLint ( code ) . ast ) ;
21+ expect ( parse ( code ) ) . toStrictEqual ( parseForESLint ( code ) . ast ) ;
1822 } ) ;
1923
2024 it ( 'parseForESLint() should work if options are `null`' , ( ) => {
2125 const code = 'const valid = true;' ;
22- expect ( ( ) => parseForESLint ( code , null ) ) . not . toThrow ( ) ;
26+ expect ( ( ) => {
27+ parseForESLint ( code , null ) ;
28+ } ) . not . toThrow ( ) ;
2329 } ) ;
2430
2531 it ( 'parseAndGenerateServices() should be called with options' , ( ) => {
@@ -36,7 +42,7 @@ describe('parser', () => {
3642 extraFileExtensions : [ '.foo' ] ,
3743 filePath : './isolated-file.src.ts' ,
3844 project : 'tsconfig.json' ,
39- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
45+ tsconfigRootDir : FIXTURES_DIR ,
4046 } ;
4147 parseForESLint ( code , config ) ;
4248 expect ( spy ) . toHaveBeenCalledExactlyOnceWith ( code , {
@@ -107,7 +113,7 @@ describe('parser', () => {
107113 errorOnTypeScriptSyntacticAndSemanticIssues : false ,
108114 filePath : 'isolated-file.src.ts' ,
109115 project : 'tsconfig.json' ,
110- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
116+ tsconfigRootDir : FIXTURES_DIR ,
111117 } ;
112118
113119 parseForESLint ( code , config ) ;
@@ -141,7 +147,7 @@ describe('parser', () => {
141147 const config : ParserOptions = {
142148 filePath : 'isolated-file.src.ts' ,
143149 project : 'tsconfig.json' ,
144- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
150+ tsconfigRootDir : FIXTURES_DIR ,
145151 } ;
146152
147153 vi . spyOn (
@@ -185,7 +191,7 @@ describe('parser', () => {
185191 extraFileExtensions : [ '.foo' ] ,
186192 filePath : 'isolated-file.src.ts' ,
187193 project : 'tsconfig.json' ,
188- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
194+ tsconfigRootDir : FIXTURES_DIR ,
189195 } ;
190196
191197 parseForESLint ( code , config ) ;
0 commit comments