Skip to content

Support for RegExp when specifying paths #38

@bruno-delfino1995

Description

@bruno-delfino1995

Given this project is based on Nock, I supposed that it handled RegExp for specifying paths as Nock does.

I tested using the code provided in the README.md with some changes to match a path using a RegExp. Here follows

const http = require('http')
const hock = require('hock')
const request = require('request')

const mock = hock.createHock()
mock
  .get(/source$/)
  .reply(200, 'Hello!')

const server = http.createServer(mock.handler)
server.listen(1337, function () {
  console.log('Hock server listening at http://localhost:1337')
})

process.on('uncaughtException', (err) => {
  console.log('Whoops! There was an uncaught error\n', err)
})

When accessing http://localhost:1337/source I get an error for a non-matching route. Do you have any plan to support RegExp as Nock does?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions