Skip to content

Commit a284cbf

Browse files
committed
[Tests] switch from jest to tape
This allows us to: - drop all the jest mocks - no longer be stuck on an EOL version nor be forced to raise the engines.node threshold - run tests 4x faster: jest takes 27.365s, tape takes 7.086s
1 parent deac4fd commit a284cbf

40 files changed

+1723
-1315
lines changed

.github/workflows/node-4+.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
skip-ls-check: true
129129
- run: rm __tests__/src/util/getComputedRole-test.js
130130
if: ${{ matrix.node-version < 7 }}
131-
- run: npm run test:ci
131+
- run: npm run tests-only
132132
- uses: codecov/[email protected]
133133

134134
node:

__tests__/__util__/nodeReexports/assert.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/__util__/nodeReexports/fs-promises.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/__util__/nodeReexports/fs.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/__util__/nodeReexports/path.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/__util__/nodeReexports/url.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/__util__/nodeReexports/util.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/index-test.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,39 @@
22

33
import fs from 'fs';
44
import path from 'path';
5-
import expect from 'expect';
5+
import test from 'tape';
6+
67
import plugin from '../src';
78

89
const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules/'))
910
.map((f) => path.basename(f, '.js'));
1011

11-
describe('all rule files should be exported by the plugin', () => {
12+
test('all rule files should be exported by the plugin', (t) => {
1213
rules.forEach((ruleName) => {
13-
it(`should export ${ruleName}`, () => {
14-
expect(plugin.rules[ruleName]).toEqual(
15-
require(path.join('../src/rules', ruleName)) // eslint-disable-line
16-
);
17-
});
14+
t.equal(
15+
plugin.rules[ruleName],
16+
require(path.join('../src/rules', ruleName)), // eslint-disable-line import/no-dynamic-require
17+
`exports ${ruleName}`,
18+
);
1819
});
20+
21+
t.end();
1922
});
2023

21-
describe('configurations', () => {
22-
it('should export a \'recommended\' configuration', () => {
23-
expect(plugin.configs.recommended).toBeDefined();
24-
});
24+
test('configurations', (t) => {
25+
t.notEqual(plugin.configs.recommended, undefined, 'exports a \'recommended\' configuration');
26+
27+
t.end();
2528
});
2629

27-
describe('schemas', () => {
30+
test('schemas', (t) => {
2831
rules.forEach((ruleName) => {
29-
it(`${ruleName} should export a schema with type object`, () => {
30-
const rule = require(path.join('../src/rules', ruleName)); // eslint-disable-line
31-
const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
32-
const { type } = schema;
32+
const rule = require(path.join('../src/rules', ruleName)); // eslint-disable-line import/no-dynamic-require
33+
const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
34+
const { type } = schema;
3335

34-
expect(type).toEqual('object');
35-
});
36+
t.equal(type, 'object', `${ruleName} exports a schema with type object`);
3637
});
38+
39+
t.end();
3740
});

__tests__/src/rules/anchor-ambiguous-text-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env jest */
21
/**
32
* @fileoverview Enforce `<a>` text to not exactly match "click here", "here", "link", or "a link".
43
* @author Matt Wang

__tests__/src/rules/aria-proptypes-test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
import { aria } from 'aria-query';
1111
import { RuleTester } from 'eslint';
12-
import expect from 'expect';
12+
import test from 'tape';
13+
1314
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
1415
import parsers from '../../__util__/helpers/parsers';
1516
import rule from '../../../src/rules/aria-proptypes';
@@ -51,13 +52,14 @@ tokens from the following: ${permittedValues}.`,
5152
}
5253
};
5354

54-
describe('validityCheck', () => {
55-
it('should false for an unknown expected type', () => {
56-
expect(validityCheck(
57-
null,
58-
null,
59-
)).toBe(false);
60-
});
55+
test('validityCheck', (t) => {
56+
t.equal(
57+
validityCheck(null, null),
58+
false,
59+
'is false for an unknown expected type',
60+
);
61+
62+
t.end();
6163
});
6264

6365
ruleTester.run('aria-proptypes', rule, {

0 commit comments

Comments
 (0)