-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
parse.moduleResolver.placeholder-error.test.ts
42 lines (37 loc) · 1.32 KB
/
parse.moduleResolver.placeholder-error.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { resolve } from 'path';
import * as parser from '../../src';
import { createAndPrepareParseConfig } from '../../tools/test-utils';
beforeEach(() => {
jest.clearAllMocks();
});
describe('parseAndGenerateServices', () => {
describe('moduleResolver', () => {
const { code, config, projectDirectory } = createAndPrepareParseConfig();
describe('when file is in the project', () => {
it('returns error if __PLACEHOLDER__ can not be resolved', () => {
expect(
parser
.parseAndGenerateServices(code, config)
.services.program!.getSemanticDiagnostics(),
).toHaveProperty(
[0, 'messageText'],
"Cannot find module '__PLACEHOLDER__' or its corresponding type declarations.",
);
});
it('throws error if moduleResolver can not be found', () => {
expect(() =>
parser.parseAndGenerateServices(code, {
...config,
moduleResolver: resolve(
projectDirectory,
'./this_moduleResolver_does_not_exist.js',
),
}),
).toThrowErrorMatchingInlineSnapshot(`
"Could not find the provided parserOptions.moduleResolver.
Hint: use an absolute path if you are not in control over where the ESLint instance runs."
`);
});
});
});
});