Skip to content

Commit 9468f05

Browse files
committed
Test: Radically simplify integration test reference data
Remove all the computed indirection from the test fixtures. The expected/reference values should be as plain as possible so that it is easy to change things, and easy to review and confirm how things are supposed to work, and to have high confidence in the results when they arre passing. Previously, the expected results were complicated and thus presented their own source of potential bugs and require debugging. Instead: - Use object literals for the expected values. - Use propEqual() for comparing actual with expected. - Any tolerance or mutation is done in a single place, before the tests begin.
1 parent 47914da commit 9468f05

File tree

6 files changed

+647
-439
lines changed

6 files changed

+647
-439
lines changed

test/fixtures/integration/jasmine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ describe('suite with tests', function () {
3636
});
3737
});
3838

39-
describe('outter suite', function () {
40-
it('outter test', function () {
39+
describe('outer suite', function () {
40+
it('outer test', function () {
4141
expect(true).toBeTruthy();
4242
});
4343

test/fixtures/integration/mocha.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ describe('suite with tests', function () {
3636
});
3737
});
3838

39-
describe('outter suite', function () {
39+
describe('outer suite', function () {
4040
describe('inner suite', function () {
4141
it('inner test', function () {
4242

4343
});
4444
});
4545

46-
it('outter test', function () {
46+
it('outer test', function () {
4747

4848
});
4949
});

test/fixtures/integration/qunit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ QUnit.test('should fail', function () {
3232
throw new Error('error');
3333
});
3434

35-
QUnit.module('outter suite', function () {
35+
QUnit.module('outer suite', function () {
3636
QUnit.module('inner suite', function () {
3737
QUnit.test('inner test', function (assert) {
3838
assert.ok(true);
3939
});
4040
});
4141

42-
QUnit.test('outter test', function (assert) {
42+
QUnit.test('outer test', function (assert) {
4343
assert.ok(true);
4444
});
4545
});

test/integration/adapters-run.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function rerequire (file) {
1919
* against a default test fixture.
2020
*/
2121
module.exports = {
22-
Jasmine: function (attachListeners) {
22+
Jasmine: function (collectData) {
2323
const Jasmine = rerequire('jasmine');
2424
const jasmine = new Jasmine();
2525

@@ -46,45 +46,45 @@ module.exports = {
4646
jasmine.completionReporter.onComplete(function () {});
4747
}
4848
const jasmineRunner = new JsReporters.JasmineAdapter(jasmine);
49-
attachListeners(jasmineRunner);
49+
collectData(jasmineRunner);
5050

5151
jasmine.execute();
5252
},
5353

54-
'QUnit (1.x)': function (attachListeners) {
54+
'QUnit (1.x)': function (collectData) {
5555
// Legacy npm package name
5656
const QUnit = rerequire('qunitjs');
5757
global.QUnit = QUnit;
5858
QUnit.config.autorun = false;
5959

6060
const qunitRunner = new JsReporters.QUnitAdapter(QUnit);
61-
attachListeners(qunitRunner);
61+
collectData(qunitRunner);
6262

6363
rerequire(path.join(testDir, 'qunit.js'));
6464

6565
QUnit.load();
6666
},
67-
QUnit: function (attachListeners) {
67+
QUnit: function (collectData) {
6868
// Get a reporter context independent of the integration test suite itself
6969
const QUnit = rerequire('qunit');
7070
global.QUnit = QUnit;
7171
QUnit.config.autorun = false;
7272

7373
const qunitRunner = new JsReporters.QUnitAdapter(QUnit);
74-
attachListeners(qunitRunner);
74+
collectData(qunitRunner);
7575

7676
rerequire(path.join(testDir, 'qunit.js'));
7777

7878
QUnit.start();
7979
},
80-
Mocha: function (attachListeners) {
80+
Mocha: function (collectData) {
8181
const Mocha = rerequire('mocha');
8282
const mocha = new Mocha();
8383
mocha.addFile(path.join(testDir, 'mocha.js'));
8484

8585
const mochaRunner = new JsReporters.MochaAdapter(mocha);
8686

87-
attachListeners(mochaRunner);
87+
collectData(mochaRunner);
8888
mocha.run();
8989
}
9090
};

0 commit comments

Comments
 (0)