-
-
Save nivsherf/4934b3cfae657a93302f11df207e32b4 to your computer and use it in GitHub Desktop.
Global RegExp in nock path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const nock = require('./index'); | |
const request = require('superagent'); | |
const testMock = async (regexp) => { | |
const scope = nock('https://api.github.com') | |
.get(regexp).reply(200, { foo: 'bar' }); | |
try { | |
const response = await request.get('https://api.github.com/repos/atom/atom/license'); | |
scope.done(); | |
console.log('Got a response!', regexp, response.body); | |
} catch (err) { | |
console.log('error for regexp', regexp, err); | |
throw err; | |
} | |
} | |
testMock(/repos.*/).then(() => testMock(/repos.*/g)).catch(() => process.exit(1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment