1
- /* eslint-env mocha */
1
+ /* eslint-env qunit */
2
2
/* eslint-disable no-unused-expressions */
3
3
4
- const expect = require ( 'chai' ) . expect ;
4
+ const { test } = QUnit ;
5
5
const refData = require ( './reference-data.js' ) ;
6
6
const runAdapters = require ( './adapters-run.js' ) ;
7
7
@@ -150,21 +150,10 @@ function getTestCountsEnd (refSuite) {
150
150
total : refSuite . tests . length
151
151
} ;
152
152
153
- testCounts . passed += refSuite . tests . filter ( function ( test ) {
154
- return test . status === 'passed' ;
155
- } ) . length ;
156
-
157
- testCounts . failed += refSuite . tests . filter ( function ( test ) {
158
- return test . status === 'failed' ;
159
- } ) . length ;
160
-
161
- testCounts . skipped += refSuite . tests . filter ( function ( test ) {
162
- return test . status === 'skipped' ;
163
- } ) . length ;
164
-
165
- testCounts . todo += refSuite . tests . filter ( function ( test ) {
166
- return test . status === 'todo' ;
167
- } ) . length ;
153
+ testCounts . passed += refSuite . tests . filter ( test => test . status === 'passed' ) . length ;
154
+ testCounts . failed += refSuite . tests . filter ( test => test . status === 'failed' ) . length ;
155
+ testCounts . skipped += refSuite . tests . filter ( test => test . status === 'skipped' ) . length ;
156
+ testCounts . todo += refSuite . tests . filter ( test => test . status === 'todo' ) . length ;
168
157
169
158
refSuite . childSuites . forEach ( function ( childSuite ) {
170
159
const childTestCounts = getTestCountsEnd ( childSuite ) ;
@@ -179,106 +168,89 @@ function getTestCountsEnd (refSuite) {
179
168
return testCounts ;
180
169
}
181
170
182
- describe ( 'Adapters integration' , function ( ) {
171
+ QUnit . module ( 'Adapters integration' , function ( ) {
183
172
Object . keys ( runAdapters ) . forEach ( function ( adapter ) {
184
- describe ( adapter + ' adapter' , function ( ) {
173
+ QUnit . module ( adapter + ' adapter' , hooks => {
185
174
const keys = [ 'passed' , 'actual' , 'expected' , 'message' , 'stack' , 'todo' ] ;
186
175
187
- before ( function ( done ) {
176
+ hooks . before ( assert => {
177
+ const done = assert . async ( ) ;
188
178
collectedData = [ ] ;
189
179
runAdapters [ adapter ] ( _attachListeners . bind ( null , done ) ) ;
190
180
} ) ;
191
181
192
- it ( 'tests runtime should be a number ', function ( ) {
193
- collectedData . forEach ( function ( value ) {
182
+ test ( 'Event "testEnd" runtime property ', assert => {
183
+ collectedData . forEach ( value => {
194
184
if ( value [ 0 ] === 'testEnd' && value [ 1 ] . status !== 'skipped' ) {
195
- expect ( value [ 1 ] . runtime ) . to . be . a ( 'number' ) ;
185
+ assert . equal ( typeof value [ 1 ] . runtime , 'number' ) ;
196
186
}
197
187
} ) ;
198
188
} ) ;
199
189
200
- it ( 'testing tests errors prop' , function ( ) {
201
- const refTestsEnd = refData . filter ( function ( value ) {
202
- return value [ 0 ] === 'testEnd' ;
203
- } ) ;
190
+ test ( 'Event "testEnd" errors property' , assert => {
191
+ const refTestsEnd = refData . filter ( value => value [ 0 ] === 'testEnd' ) ;
192
+ const testsEnd = collectedData . filter ( value => value [ 0 ] === 'testEnd' ) ;
204
193
205
- const testsEnd = collectedData . filter ( function ( value ) {
206
- return value [ 0 ] === 'testEnd' ;
207
- } ) ;
208
-
209
- refTestsEnd . forEach ( function ( value , index ) {
194
+ refTestsEnd . forEach ( ( value , index ) => {
210
195
const refTest = value [ 1 ] ;
211
196
const test = testsEnd [ index ] [ 1 ] ;
212
197
213
198
if ( refTest . status === 'passed' || refTest . status === 'skipped' ) {
214
- expect ( test . errors ) . to . be . deep . equal ( refTest . errors ) ;
199
+ assert . deepEqual ( test . errors , refTest . errors ) ;
215
200
} else {
216
- expect ( test . errors ) . to . have . lengthOf ( refTest . errors . length ) ;
201
+ assert . equal ( test . errors . length , refTest . errors . length ) ;
217
202
218
- test . errors . forEach ( function ( error ) {
219
- expect ( error ) . to . have . all . keys ( keys ) ;
203
+ test . errors . forEach ( error => {
204
+ assert . deepEqual ( Object . keys ( error ) , keys ) ;
220
205
221
- expect ( error . passed ) . to . be . false ;
222
- expect ( error . message ) . to . be . a ( 'string' ) ;
223
- expect ( error . stack ) . to . be . a ( 'string' ) ;
206
+ assert . false ( error . passed ) ;
207
+ assert . strictEqual ( typeof error . message , 'string' ) ;
208
+ assert . strictEqual ( typeof error . stack , 'string' ) ;
224
209
} ) ;
225
210
}
226
211
} ) ;
227
212
} ) ;
228
213
229
- it ( 'testing tests assertions prop' , function ( ) {
230
- const refTestsEnd = refData . filter ( function ( value ) {
231
- return value [ 0 ] === 'testEnd' ;
232
- } ) ;
214
+ test ( 'Event "testEnd" assertions property' , assert => {
215
+ const refTestsEnd = refData . filter ( value => value [ 0 ] === 'testEnd' ) ;
216
+ const testsEnd = collectedData . filter ( value => value [ 0 ] === 'testEnd' ) ;
233
217
234
- const testsEnd = collectedData . filter ( function ( value ) {
235
- return value [ 0 ] === 'testEnd' ;
236
- } ) ;
237
-
238
- refTestsEnd . forEach ( function ( value , index ) {
218
+ refTestsEnd . forEach ( ( value , index ) => {
239
219
const refTest = value [ 1 ] ;
240
220
const test = testsEnd [ index ] [ 1 ] ;
241
221
242
222
// Expect to contain the correct number of assertions, only for
243
223
// test frameworks that provide all assertions.
244
224
if ( adapter !== 'Mocha' ) {
245
- expect ( test . assertions ) . to . have . lengthOf ( refTest . assertions . length ) ;
225
+ assert . strictEqual ( test . assertions . length , refTest . assertions . length ) ;
246
226
}
247
227
248
- const passedAssertions = test . assertions . filter ( function ( assertion ) {
249
- return assertion . passed ;
250
- } ) ;
251
-
252
- const failedAssertions = test . assertions . filter ( function ( assertion ) {
253
- return ! assertion . passed ;
254
- } ) ;
228
+ const passedAssertions = test . assertions . filter ( assertion => assertion . passed ) ;
229
+ const failedAssertions = test . assertions . filter ( assertion => ! assertion . passed ) ;
255
230
256
- passedAssertions . forEach ( function ( assertion ) {
257
- expect ( assertion ) . to . have . all . keys ( keys ) ;
231
+ passedAssertions . forEach ( assertion => {
232
+ assert . deepEqual ( Object . keys ( assertion ) , keys ) ;
258
233
259
- expect ( assertion . passed ) . to . be . true ;
260
- expect ( assertion . message ) . to . be . a ( 'string' ) ;
261
- expect ( assertion . stack ) . to . be . undefined ;
234
+ assert . true ( assertion . passed ) ;
235
+ assert . strictEqual ( typeof assertion . message , 'string' ) ;
236
+ assert . strictEqual ( assertion . stack , undefined ) ;
262
237
} ) ;
263
238
264
- failedAssertions . forEach ( function ( assertion ) {
265
- expect ( assertion ) . to . have . all . keys ( keys ) ;
239
+ failedAssertions . forEach ( assertion => {
240
+ assert . deepEqual ( Object . keys ( assertion ) , keys ) ;
266
241
267
- expect ( assertion . passed ) . to . be . false ;
268
- expect ( assertion . message ) . to . be . a ( 'string' ) ;
269
- expect ( assertion . stack ) . to . be . a ( 'string' ) ;
242
+ assert . false ( assertion . passed ) ;
243
+ assert . strictEqual ( typeof assertion . message , 'string' ) ;
244
+ assert . strictEqual ( typeof assertion . stack , 'string' ) ;
270
245
} ) ;
271
246
} ) ;
272
247
} ) ;
273
248
274
- refData . forEach ( function ( value , index ) {
275
- const testDescription = value [ 2 ] ;
249
+ refData . forEach ( ( value , index ) => {
250
+ const [ refEvent , refTestItem , refTestDescription ] = value ;
276
251
277
- it ( testDescription , function ( ) {
278
- const refEvent = value [ 0 ] ;
279
- const refTestItem = value [ 1 ] ;
280
- const event = collectedData [ index ] [ 0 ] ;
281
- const testItem = collectedData [ index ] [ 1 ] ;
252
+ test ( refTestDescription , assert => {
253
+ const [ event , testItem ] = collectedData [ index ] ;
282
254
283
255
// Set tests runtime to 0 to match the reference tests runtime.
284
256
if ( event === 'testEnd' && testItem . status !== 'skipped' ) {
@@ -310,33 +282,37 @@ describe('Adapters integration', function () {
310
282
311
283
// Verify suite self-setting props.
312
284
if ( event === 'suiteStart' || event === 'runStart' ) {
313
- expect ( testItem . status ) . to . be . undefined ;
314
- expect ( testItem . runtime ) . to . be . undefined ;
285
+ assert . strictEqual ( testItem . status , undefined ) ;
286
+ assert . strictEqual ( testItem . runtime , undefined ) ;
315
287
316
- expect ( testItem . testCounts ) . to . be . deep
317
- . equal ( getTestCountsStart ( refTestItem ) ) ;
288
+ assert . deepEqual ( testItem . testCounts , getTestCountsStart ( refTestItem ) ) ;
318
289
}
319
290
320
291
// Verify suite self-setting props.
321
292
if ( event === 'suiteEnd' || event === 'runEnd' ) {
322
293
const refStatus = value [ 3 ] ;
323
294
324
- expect ( testItem . status ) . to . be . equal ( refStatus ) ;
295
+ assert . strictEqual ( testItem . status , refStatus ) ;
325
296
326
297
if ( testItem . status !== 'skipped' ) {
327
- expect ( testItem . runtime ) . to . be . a ( 'number' ) ;
298
+ assert . strictEqual ( typeof testItem . runtime , 'number' ) ;
328
299
// Set suites runtime to 0, to pass the deep equal assertion.
329
300
_setSuitesRuntime ( testItem ) ;
330
301
} else {
331
- expect ( testItem . runtime ) . to . be . undefined ;
302
+ assert . strictEqual ( testItem . runtime , undefined ) ;
332
303
}
333
304
334
- expect ( testItem . testCounts ) . to . be . deep
335
- . equal ( getTestCountsEnd ( refTestItem ) ) ;
305
+ assert . deepEqual ( testItem . testCounts , getTestCountsEnd ( refTestItem ) ) ;
336
306
}
337
307
338
- expect ( event ) . equal ( refEvent ) ;
339
- expect ( testItem ) . to . be . deep . equal ( refTestItem ) ;
308
+ assert . strictEqual ( event , refEvent ) ;
309
+
310
+ // FIXME: Ref data has TestEnd#assertions as plain objects instead of Assertion objects.
311
+ // > not ok 6 Adapters integration > Jasmine adapter > global test ends
312
+ // actual : assertions: [ Assertion { passed: true, … } ]
313
+ // expected: assertions: [ { passed: true, … } ]
314
+ // assert.deepEqual(testItem, refTestItem);
315
+ assert . propEqual ( testItem , refTestItem ) ;
340
316
} ) ;
341
317
} ) ;
342
318
} ) ;
0 commit comments