Skip to content

Commit

Permalink
Remove chai (#1725)
Browse files Browse the repository at this point in the history
* remove chai

* fix
  • Loading branch information
cspotcode committed Apr 19, 2022
1 parent 1efabf4 commit d7670e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 85 deletions.
59 changes: 0 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -114,7 +114,6 @@
"@microsoft/api-extractor": "^7.19.4",
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/chai": "^4.0.4",
"@types/diff": "^4.0.2",
"@types/lodash": "^4.14.151",
"@types/node": "13.13.5",
Expand All @@ -126,7 +125,6 @@
"@yarnpkg/fslib": "^2.4.0",
"ava": "^3.15.0",
"axios": "^0.21.1",
"chai": "^4.0.1",
"dprint": "^0.25.0",
"expect": "^27.0.2",
"get-stream": "^6.0.0",
Expand Down
39 changes: 19 additions & 20 deletions src/test/register.spec.ts
Expand Up @@ -6,8 +6,7 @@ import {
TEST_DIR,
tsNodeTypes,
} from './helpers';
import { context } from './testlib';
import { expect } from 'chai';
import { context, expect } from './testlib';
import * as exp from 'expect';
import { join, resolve } from 'path';
import proxyquire = require('proxyquire');
Expand Down Expand Up @@ -74,51 +73,51 @@ test.suite('register(create(options))', (test) => {
}) => {
const m = require(moduleTestPath);

expect(m.example('foo')).to.equal('FOO');
expect(m.example('foo')).toBe('FOO');
});

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

expect(service.enabled(false)).to.equal(false);
expect(() => require(moduleTestPath)).to.throw(/Unexpected token/);
expect(service.enabled(false)).toBe(false);
expect(() => require(moduleTestPath)).toThrow(/Unexpected token/);

delete require.cache[moduleTestPath];

expect(service.enabled()).to.equal(false);
expect(() => require(moduleTestPath)).to.throw(/Unexpected token/);
expect(service.enabled()).toBe(false);
expect(() => require(moduleTestPath)).toThrow(/Unexpected token/);

delete require.cache[moduleTestPath];

expect(service.enabled(true)).to.equal(true);
expect(() => require(moduleTestPath)).to.not.throw();
expect(service.enabled(true)).toBe(true);
expect(() => require(moduleTestPath)).not.toThrow();

delete require.cache[moduleTestPath];

expect(service.enabled()).to.equal(true);
expect(() => require(moduleTestPath)).to.not.throw();
expect(service.enabled()).toBe(true);
expect(() => require(moduleTestPath)).not.toThrow();
});

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

expect(m.example()).to.equal('example');
expect(m.example()).toBe('example');
});

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

expect(m.example()).to.equal('hello');
expect(m.example()).toBe('hello');
});

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

expect(example1).to.not.equal(example2);
expect(example1).not.toBe(example2);
});

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

expect(compiled).to.match(SOURCE_MAP_REGEXP);
expect(compiled).toMatch(SOURCE_MAP_REGEXP);
});
});
});
Expand Down Expand Up @@ -190,18 +189,18 @@ test('should support compiler scopes w/multiple registered compiler services at
});

try {
expect(require('../../tests/scope/a').ext).to.equal('.ts');
expect(require('../../tests/scope/b').ext).to.equal('.ts');
expect(require('../../tests/scope/a').ext).toBe('.ts');
expect(require('../../tests/scope/b').ext).toBe('.ts');
} finally {
compilers.forEach((c) => c.enabled(false));
}

expect(calls).to.deep.equal([
expect(calls).toEqual([
join(TEST_DIR, 'scope/a/index.ts'),
join(TEST_DIR, 'scope/b/index.ts'),
]);

delete require.cache[moduleTestPath];

expect(() => require(moduleTestPath)).to.throw();
expect(() => require(moduleTestPath)).toThrow();
});
8 changes: 4 additions & 4 deletions src/test/repl/node-repl-tla.ts
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { expect } from '../testlib';
import type { Key } from 'readline';
import { Stream } from 'stream';
import semver = require('semver');
Expand Down Expand Up @@ -246,12 +246,12 @@ export async function upstreamTopLevelAwaitTests({
if (Array.isArray(expected)) {
if (expected.length === 1) expected.push('undefined');
if (lines[0] === input) lines.shift();
expect(lines).to.eqls([...expected, PROMPT]);
expect(lines).toEqual([...expected, PROMPT]);
} else if ('line' in options) {
expect(lines[toBeRun.length + options.line!]).to.eqls(expected);
expect(lines[toBeRun.length + options.line!]).toEqual(expected);
} else {
const echoed = toBeRun.map((a, i) => `${i > 0 ? '... ' : ''}${a}\r`);
expect(lines).to.eqls([...echoed, expected, PROMPT]);
expect(lines).toEqual([...echoed, expected, PROMPT]);
}
}
}
Expand Down

0 comments on commit d7670e9

Please sign in to comment.