Skip to content

Commit d7670e9

Browse files
authored
Remove chai (#1725)
* remove chai * fix
1 parent 1efabf4 commit d7670e9

File tree

4 files changed

+23
-85
lines changed

4 files changed

+23
-85
lines changed

package-lock.json

Lines changed: 0 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
"@microsoft/api-extractor": "^7.19.4",
115115
"@swc/core": ">=1.2.50",
116116
"@swc/wasm": ">=1.2.50",
117-
"@types/chai": "^4.0.4",
118117
"@types/diff": "^4.0.2",
119118
"@types/lodash": "^4.14.151",
120119
"@types/node": "13.13.5",
@@ -126,7 +125,6 @@
126125
"@yarnpkg/fslib": "^2.4.0",
127126
"ava": "^3.15.0",
128127
"axios": "^0.21.1",
129-
"chai": "^4.0.1",
130128
"dprint": "^0.25.0",
131129
"expect": "^27.0.2",
132130
"get-stream": "^6.0.0",

src/test/register.spec.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
TEST_DIR,
77
tsNodeTypes,
88
} from './helpers';
9-
import { context } from './testlib';
10-
import { expect } from 'chai';
9+
import { context, expect } from './testlib';
1110
import * as exp from 'expect';
1211
import { join, resolve } from 'path';
1312
import proxyquire = require('proxyquire');
@@ -74,51 +73,51 @@ test.suite('register(create(options))', (test) => {
7473
}) => {
7574
const m = require(moduleTestPath);
7675

77-
expect(m.example('foo')).to.equal('FOO');
76+
expect(m.example('foo')).toBe('FOO');
7877
});
7978

8079
test('should support dynamically disabling', ({
8180
context: { service, moduleTestPath },
8281
}) => {
8382
delete require.cache[moduleTestPath];
8483

85-
expect(service.enabled(false)).to.equal(false);
86-
expect(() => require(moduleTestPath)).to.throw(/Unexpected token/);
84+
expect(service.enabled(false)).toBe(false);
85+
expect(() => require(moduleTestPath)).toThrow(/Unexpected token/);
8786

8887
delete require.cache[moduleTestPath];
8988

90-
expect(service.enabled()).to.equal(false);
91-
expect(() => require(moduleTestPath)).to.throw(/Unexpected token/);
89+
expect(service.enabled()).toBe(false);
90+
expect(() => require(moduleTestPath)).toThrow(/Unexpected token/);
9291

9392
delete require.cache[moduleTestPath];
9493

95-
expect(service.enabled(true)).to.equal(true);
96-
expect(() => require(moduleTestPath)).to.not.throw();
94+
expect(service.enabled(true)).toBe(true);
95+
expect(() => require(moduleTestPath)).not.toThrow();
9796

9897
delete require.cache[moduleTestPath];
9998

100-
expect(service.enabled()).to.equal(true);
101-
expect(() => require(moduleTestPath)).to.not.throw();
99+
expect(service.enabled()).toBe(true);
100+
expect(() => require(moduleTestPath)).not.toThrow();
102101
});
103102

104103
test('should compile through js and ts', () => {
105104
const m = require('../../tests/complex');
106105

107-
expect(m.example()).to.equal('example');
106+
expect(m.example()).toBe('example');
108107
});
109108

110109
test('should work with proxyquire', () => {
111110
const m = proxyquire('../../tests/complex', {
112111
'./example': 'hello',
113112
});
114113

115-
expect(m.example()).to.equal('hello');
114+
expect(m.example()).toBe('hello');
116115
});
117116

118117
test('should work with `require.cache`', () => {
119118
const { example1, example2 } = require('../../tests/require-cache');
120119

121-
expect(example1).to.not.equal(example2);
120+
expect(example1).not.toBe(example2);
122121
});
123122

124123
test('should use source maps', async () => {
@@ -155,10 +154,10 @@ test.suite('register(create(options))', (test) => {
155154
try {
156155
require('../../tests/with-jsx.tsx');
157156
} catch (error: any) {
158-
expect(error.stack).to.contain('SyntaxError: Unexpected token');
157+
expect(error.stack).toMatch('SyntaxError: Unexpected token');
159158
}
160159

161-
expect(compiled).to.match(SOURCE_MAP_REGEXP);
160+
expect(compiled).toMatch(SOURCE_MAP_REGEXP);
162161
});
163162
});
164163
});
@@ -190,18 +189,18 @@ test('should support compiler scopes w/multiple registered compiler services at
190189
});
191190

192191
try {
193-
expect(require('../../tests/scope/a').ext).to.equal('.ts');
194-
expect(require('../../tests/scope/b').ext).to.equal('.ts');
192+
expect(require('../../tests/scope/a').ext).toBe('.ts');
193+
expect(require('../../tests/scope/b').ext).toBe('.ts');
195194
} finally {
196195
compilers.forEach((c) => c.enabled(false));
197196
}
198197

199-
expect(calls).to.deep.equal([
198+
expect(calls).toEqual([
200199
join(TEST_DIR, 'scope/a/index.ts'),
201200
join(TEST_DIR, 'scope/b/index.ts'),
202201
]);
203202

204203
delete require.cache[moduleTestPath];
205204

206-
expect(() => require(moduleTestPath)).to.throw();
205+
expect(() => require(moduleTestPath)).toThrow();
207206
});

src/test/repl/node-repl-tla.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect } from 'chai';
1+
import { expect } from '../testlib';
22
import type { Key } from 'readline';
33
import { Stream } from 'stream';
44
import semver = require('semver');
@@ -246,12 +246,12 @@ export async function upstreamTopLevelAwaitTests({
246246
if (Array.isArray(expected)) {
247247
if (expected.length === 1) expected.push('undefined');
248248
if (lines[0] === input) lines.shift();
249-
expect(lines).to.eqls([...expected, PROMPT]);
249+
expect(lines).toEqual([...expected, PROMPT]);
250250
} else if ('line' in options) {
251-
expect(lines[toBeRun.length + options.line!]).to.eqls(expected);
251+
expect(lines[toBeRun.length + options.line!]).toEqual(expected);
252252
} else {
253253
const echoed = toBeRun.map((a, i) => `${i > 0 ? '... ' : ''}${a}\r`);
254-
expect(lines).to.eqls([...echoed, expected, PROMPT]);
254+
expect(lines).toEqual([...echoed, expected, PROMPT]);
255255
}
256256
}
257257
}

0 commit comments

Comments
 (0)