Skip to content

Commit afd58ce

Browse files
tests: fix failing tests
1 parent 34681fb commit afd58ce

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

test/jobs.test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import chai from 'chai'
22
import chailint from 'chai-lint'
33
import feathers from '@feathersjs/feathers'
44
import express from '@feathersjs/express'
5+
import errors from '@feathersjs/errors'
56
import mongo from 'mongodb'
67
import path, { dirname } from 'path'
78
import nock from 'nock'
@@ -166,13 +167,14 @@ describe('krawler:jobs', () => {
166167
id: 'job',
167168
options: { faultTolerant: true, timeout: 1000 },
168169
tasks: [
169-
{ id: 'job-403-fault-tolerant.html', type: 'http', store: 'test-store', options: { url: 'https://www.google.com', timeout: 3000 } }
170+
{ id: 'job-global-timeout.html', type: 'http', store: 'test-store', options: { url: 'https://www.google.com', timeout: 3000 } }
170171
]
171172
})
172-
.then(tasks => {
173-
expect(tasks).toExist()
174-
expect(tasks.length).to.equal(1)
175-
expect(tasks[0].error).toExist(1)
173+
.catch(error => {
174+
// We expect the job to fail since job timeout < task timeout
175+
// error is an instance of featherjs error class Timeout
176+
expect(error).toExist()
177+
expect(error instanceof errors.Timeout).to.beTrue()
176178
done()
177179
})
178180
})
@@ -300,7 +302,7 @@ describe('krawler:jobs', () => {
300302
return jobsService.create({
301303
id: 'job',
302304
tasks: [
303-
{ id: 'job-apply.html', type: 'noop' }
305+
{ id: 'job-apply.html', type: 'noop', store: 'test-store' }
304306
]
305307
})
306308
.then(tasks => {
@@ -317,7 +319,7 @@ describe('krawler:jobs', () => {
317319
jobsService.create({
318320
id: 'job',
319321
tasks: [
320-
{ id: 'job-apply-error.html', type: 'noop' }
322+
{ id: 'job-apply-error.html', type: 'noop', store: 'test-store' }
321323
]
322324
})
323325
.catch(error => {
@@ -334,7 +336,7 @@ describe('krawler:jobs', () => {
334336
jobsService.create({
335337
id: 'job',
336338
tasks: [
337-
{ id: 'job-apply-error.html', type: 'noop' }
339+
{ id: 'job-apply-error.html', type: 'noop', store: 'test-store' }
338340
]
339341
})
340342
.then(tasks => {
@@ -361,7 +363,7 @@ describe('krawler:jobs', () => {
361363
jobsService.create({
362364
id: 'job',
363365
tasks: [
364-
{ id: 'job-apply-error.html', type: 'noop' }
366+
{ id: 'job-apply-error.html', type: 'noop', store: 'test-store' }
365367
]
366368
})
367369
.then(tasks => {

0 commit comments

Comments
 (0)