Open thestrugglingblack opened 5 years ago
Thanks for sharing this! I'm sorry but other than the broad strokes of what you're saying happened, I don't think I understand the issue. Is there a way to reproduce the failure or explain the fix more concretely?
I want to be sure I understand the root cause before updating the docs
The service is on node v.8 We are using
'use strict';
const tape = require('tape');
const nock = require('nock');
const quibble = require('quibble');
quibble('../package.json', { version: '1.1.1' }); const makeEndpointRequest = require('../lib/make-endpoint-request');
tape('[ makeEndpointRequest ] request returns 200', (t)=> { nock('https://localhost:3000', { reqheaders: { cli-version' : '1.1.1' } }) .get('/v1/offline/data001') .query({ 'access_token': 'TOKEN_HERE' }) .reply(200 );
offline.get('https://localhost:300/v1/offline/data001?access_token=TOKEN_HERE', (err, res)=> { t.error(err); t.deepEqual(res.statusCode, 200); t.equal(res.request.headers['cli-version'], '1.1.1'); }); t.end(); }); quibble.reset(); // <== had to add this
and the module we are testing is setup like this:
'use strict';
const request = require('request'); const { version } = require('../package.json');
const headers = { 'cli-version': version };
module.exports.get = function(url, callback) { request.get({ url: url, json: true, headers }, callback); };
With the test, I just wanted to verify that it was returning the correct header, so I had to stub out the package.json file. Using that file to pull in the version of the cli tool. When I didn't have `quibble.restore()` it made the error message in the first post. But the minute I added it in, it resolved and the test were able to execute and pass. Does this help give further context?
A-ha! I see now. And all our readme does is say:
A reset() method that undoes everything, intended to be run afterEach test runs
My apologies. We only use quibble in the context of https://github.com/testdouble/testdouble.js td.replace()
function, and its docs are pretty over-the-top in telling users to call td.reset()
in an after-each hook of their test lib.
Yeah, I'd welcome an update to the README that said this. Thank you!
Oh I see! I'll make a PR for an update in the quibble readme! Thanks for getting back to me on this!
Hey @searls ! Finally got a chance to use your library. I was writing a test for one of my functions in my company's CLI. I used quibble to help me stub out a module and it worked as planned (Thanks a million) However when I tried executing a full test and lint through the project it, I received this error:
The test runs this command
tape test/*.test.js && eslint *.js */*.js test/*/*.js
. My colleague @whyvez had encountered the same issue but was able to comb through the code to find the resolution. It wasquibble.restore()
. I didn't come across in this documentation. Is it possible if we can update the readme.md with that line to help the next user?