-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
expect-error.ts
75 lines (55 loc) · 2.45 KB
/
expect-error.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import path from 'path';
import test from 'ava';
import {verify} from './fixtures/utils';
import tsd from '..';
test('expectError for classes', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/classes')});
verify(t, diagnostics, []);
});
test('expectError for functions', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/functions')});
verify(t, diagnostics, [
[5, 0, 'error', 'Expected an error, but found none.']
]);
});
test('expectError for generics', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/generics')});
verify(t, diagnostics, []);
});
test('expectError should not ignore syntactical errors', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/syntax')});
verify(t, diagnostics, [
[4, 29, 'error', '\')\' expected.'],
[5, 22, 'error', '\',\' expected.'],
]);
});
test('expectError for values', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/values')});
verify(t, diagnostics, [
[5, 0, 'error', 'Expected an error, but found none.']
]);
});
test('expectError for values (noImplicitAny disabled)', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/values-disabled-no-implicit-any')});
verify(t, diagnostics, []);
});
test('expectError for values (exactOptionalPropertyTypes enabled)', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/enabled-exact-optional-property-types')});
verify(t, diagnostics, []);
});
test('expectError for decorators', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/decorators')});
verify(t, diagnostics, []);
});
test('expectError for experimental decorators', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/experimental-decorators')});
verify(t, diagnostics, []);
});
test('expectError should report missing diagnostic codes', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/expect-error/missing-diagnostic-code')});
verify(t, diagnostics, [
[8, 12, 'error', 'Cannot find name \'undeclared\'.'],
[5, 0, 'error', 'Expected an error, but found none.'],
[8, 0, 'error', 'Found an error that tsd does not currently support (`ts2304`), consider creating an issue on GitHub.'],
]);
});