Skip to content

Commit

Permalink
test(typescript-estree): fix tests for ts bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Nov 3, 2021
1 parent 1114e58 commit a3a89a7
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"allowJs": true
},
"include": [
"ts/included.ts",
"ts/included.tsx",
"js/included.js",
"js/included.jsx",
"ts/included01.ts",
"ts/included02.tsx",
"js/included01.js",
"js/included02.jsx",
"other/included.vue"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ The file must be included in at least one of the projects provided."

exports[`parseAndGenerateServices invalid file error messages project includes errors for not included files 1`] = `
"\\"parserOptions.project\\" has been set for @typescript-eslint/parser.
The file does not match your project config: ts/notIncluded.ts.
The file does not match your project config: ts/notIncluded0j1.ts.
The file must be included in at least one of the projects provided."
`;

exports[`parseAndGenerateServices invalid file error messages project includes errors for not included files 2`] = `
"\\"parserOptions.project\\" has been set for @typescript-eslint/parser.
The file does not match your project config: ts/notIncluded.tsx.
The file does not match your project config: ts/notIncluded02.tsx.
The file must be included in at least one of the projects provided."
`;

exports[`parseAndGenerateServices invalid file error messages project includes errors for not included files 3`] = `
"\\"parserOptions.project\\" has been set for @typescript-eslint/parser.
The file does not match your project config: js/notIncluded.js.
The file does not match your project config: js/notIncluded01.js.
The file must be included in at least one of the projects provided."
`;

exports[`parseAndGenerateServices invalid file error messages project includes errors for not included files 4`] = `
"\\"parserOptions.project\\" has been set for @typescript-eslint/parser.
The file does not match your project config: js/notIncluded.jsx.
The file does not match your project config: js/notIncluded02.jsx.
The file must be included in at least one of the projects provided."
`;

Expand Down
24 changes: 15 additions & 9 deletions packages/typescript-estree/tests/lib/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,23 +518,29 @@ describe('parseAndGenerateServices', () => {

describe('project includes', () => {
it("doesn't error for matched files", () => {
expect(testParse('ts/included.ts')).not.toThrow();
expect(testParse('ts/included.tsx')).not.toThrow();
expect(testParse('js/included.js')).not.toThrow();
expect(testParse('js/included.jsx')).not.toThrow();
expect(testParse('ts/included01.ts')).not.toThrow();
expect(testParse('ts/included02.tsx')).not.toThrow();
expect(testParse('js/included01.js')).not.toThrow();
expect(testParse('js/included02.jsx')).not.toThrow();
});

it('errors for not included files', () => {
expect(testParse('ts/notIncluded.ts')).toThrowErrorMatchingSnapshot();
expect(testParse('ts/notIncluded.tsx')).toThrowErrorMatchingSnapshot();
expect(testParse('js/notIncluded.js')).toThrowErrorMatchingSnapshot();
expect(testParse('js/notIncluded.jsx')).toThrowErrorMatchingSnapshot();
expect(
testParse('ts/notIncluded0j1.ts'),
).toThrowErrorMatchingSnapshot();
expect(
testParse('ts/notIncluded02.tsx'),
).toThrowErrorMatchingSnapshot();
expect(testParse('js/notIncluded01.js')).toThrowErrorMatchingSnapshot();
expect(
testParse('js/notIncluded02.jsx'),
).toThrowErrorMatchingSnapshot();
});
});

describe('"parserOptions.extraFileExtensions" is empty', () => {
it('should not error', () => {
expect(testParse('ts/included.ts', [])).not.toThrow();
expect(testParse('ts/included01.ts', [])).not.toThrow();
});

it('the extension does not match', () => {
Expand Down

0 comments on commit a3a89a7

Please sign in to comment.