Skip to content

Instantly share code, notes, and snippets.

@kharandziuk
Created March 8, 2017 13:22
Show Gist options
  • Save kharandziuk/839e5a5839523fbf2d8beb3e33c77a2b to your computer and use it in GitHub Desktop.
Save kharandziuk/839e5a5839523fbf2d8beb3e33c77a2b to your computer and use it in GitHub Desktop.
nock tips

Tip 1

check the .pendingMocks() after each test and don't share mocks between tests

describe('channel', function() {
    beforeEach(function() {
        nock.cleanAll()
    })

    afterEach(function() {
        expect(nock.pendingMocks()).lengthOf(0, nock.pendingMocks());
    });
    
    it('some test with mocks', function() {
        // ...
    })
})    

Tip 2

Use chai for checking the querystring. It will give you much better error message

.query(function(qObj) {
    return expect(qObj).include({
        x: '13', y: '52',
        accessId: '05051dad8ad9ea621e2ef671c9ea18ad',
        radius: '500', max: '10',
        lang: 'en-US'
    })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment