@@ -2,24 +2,30 @@ import type { ParserOptions } from '@typescript-eslint/types';
2
2
3
3
import * as scopeManager from '@typescript-eslint/scope-manager' ;
4
4
import * as typescriptESTree from '@typescript-eslint/typescript-estree' ;
5
- import path from 'node:path' ;
6
5
import { ScriptTarget } from 'typescript' ;
7
6
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' ;
9
9
10
10
describe ( 'parser' , ( ) => {
11
- beforeEach ( ( ) => {
11
+ afterEach ( ( ) => {
12
12
vi . clearAllMocks ( ) ;
13
13
} ) ;
14
14
15
+ afterAll ( ( ) => {
16
+ vi . restoreAllMocks ( ) ;
17
+ } ) ;
18
+
15
19
it ( 'parse() should return just the AST from parseForESLint()' , ( ) => {
16
20
const code = 'const valid = true;' ;
17
- expect ( parse ( code ) ) . toEqual ( parseForESLint ( code ) . ast ) ;
21
+ expect ( parse ( code ) ) . toStrictEqual ( parseForESLint ( code ) . ast ) ;
18
22
} ) ;
19
23
20
24
it ( 'parseForESLint() should work if options are `null`' , ( ) => {
21
25
const code = 'const valid = true;' ;
22
- expect ( ( ) => parseForESLint ( code , null ) ) . not . toThrow ( ) ;
26
+ expect ( ( ) => {
27
+ parseForESLint ( code , null ) ;
28
+ } ) . not . toThrow ( ) ;
23
29
} ) ;
24
30
25
31
it ( 'parseAndGenerateServices() should be called with options' , ( ) => {
@@ -36,7 +42,7 @@ describe('parser', () => {
36
42
extraFileExtensions : [ '.foo' ] ,
37
43
filePath : './isolated-file.src.ts' ,
38
44
project : 'tsconfig.json' ,
39
- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
45
+ tsconfigRootDir : FIXTURES_DIR ,
40
46
} ;
41
47
parseForESLint ( code , config ) ;
42
48
expect ( spy ) . toHaveBeenCalledExactlyOnceWith ( code , {
@@ -107,7 +113,7 @@ describe('parser', () => {
107
113
errorOnTypeScriptSyntacticAndSemanticIssues : false ,
108
114
filePath : 'isolated-file.src.ts' ,
109
115
project : 'tsconfig.json' ,
110
- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
116
+ tsconfigRootDir : FIXTURES_DIR ,
111
117
} ;
112
118
113
119
parseForESLint ( code , config ) ;
@@ -141,7 +147,7 @@ describe('parser', () => {
141
147
const config : ParserOptions = {
142
148
filePath : 'isolated-file.src.ts' ,
143
149
project : 'tsconfig.json' ,
144
- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
150
+ tsconfigRootDir : FIXTURES_DIR ,
145
151
} ;
146
152
147
153
vi . spyOn (
@@ -185,7 +191,7 @@ describe('parser', () => {
185
191
extraFileExtensions : [ '.foo' ] ,
186
192
filePath : 'isolated-file.src.ts' ,
187
193
project : 'tsconfig.json' ,
188
- tsconfigRootDir : path . join ( __dirname , '..' , 'fixtures' , 'services' ) ,
194
+ tsconfigRootDir : FIXTURES_DIR ,
189
195
} ;
190
196
191
197
parseForESLint ( code , config ) ;
0 commit comments