Skip to content

Commit ed40e09

Browse files
committed
Debug travis test issues
1 parent 37a4edd commit ed40e09

1 file changed

Lines changed: 34 additions & 11 deletions

File tree

test/test-test.js

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
11
const sinon = require('sinon')
22

3+
const stubFetch = () => {
4+
sinon.stub(global, 'fetch').callsFake(() => Promise.resolve())
5+
console.log('Stubbed fetch? ', fetch, !!fetch.restore)
6+
console.log('Stubbed global.fetch? ', global.fetch, !!global.fetch.restore)
7+
}
8+
9+
const doAssertions = () => {
10+
console.log('(inside test) Stubbed fetch? ', fetch, !!fetch.restore)
11+
expect(fetch.restore).to.be.a('function')
12+
}
13+
14+
const restore = () => {
15+
global.fetch.restore()
16+
}
17+
318
describe.only('Travis debug test', () => {
4-
beforeEach(() => {
5-
// console.log('Stubbing fetch:', fetch)
6-
expect(fetch).to.be.a('function')
7-
sinon.stub(global, 'fetch').callsFake(() => Promise.resolve())
8-
console.log('Stubbed fetch? ', fetch, !!fetch.restore)
9-
console.log('Stubbed global.fetch? ', global.fetch, !!global.fetch.restore)
10-
})
19+
describe('Working everywhere', () => {
20+
beforeEach(() => {
21+
expect(fetch).to.be.a('function')
1122

12-
afterEach(() => {
13-
global.fetch.restore()
23+
stubFetch()
24+
})
25+
26+
afterEach(() => {
27+
global.fetch.restore()
28+
})
29+
30+
it('should show that fetch is stubbed', doAssertions)
1431
})
1532

16-
it('should show that fetch is stubbed', async () => {
17-
console.log('(inside test) Stubbed fetch? ', fetch, !!fetch.restore)
33+
describe('Failing in Travis', () => {
34+
beforeEach(() => {
35+
stubFetch()
36+
})
37+
38+
afterEach(restore)
39+
40+
it('should show that fetch is stubbed', doAssertions)
1841
})
1942
})

0 commit comments

Comments
 (0)