nock

How to build nock regex for dynamic urls

限于喜欢 提交于 2019-12-07 22:30:45
问题 How do i build nock configuration for the following types of urls http://example.com/harry/potter?param1=value1 and http://example.com/harry/<value1> I have two type of urls first is where i can have query params altough the base url is fixed. Second one is where base url has dynamic values. Currently i have before(function(){ nock('http://example.com') .get('/terminal/chrome_log') .reply(200, "OK"); nock('http://example.com') .get(function(uri) { return uri.indexOf('harry') >= 0; }) .reply

Nock is not intercepting API call in Redux test

橙三吉。 提交于 2019-12-07 00:33:08
问题 I'm trying to test an api call in a redux app. The code pretty much follows the pattern outlined in the Async Action Creators section of the redux docs: http://redux.js.org/docs/recipes/WritingTests.html The gist of it is that you use redux-mock-store to record and assert against any actions that are triggered. This is the whole test, using nock to mock the api call: import React from 'React' import ReactDOM from 'react-dom' import expect from 'expect'; import expectJSX from 'expect-jsx';

mocking server for SSR react app e2e tests with cypress.io

人走茶凉 提交于 2019-12-06 14:43:50
I'm building a single page web application (SPA) with server side rendering (SSR). We have a node backend API which is called both from the node server during SSR and from the browser after initial rendering. I want to write e2e tests that configures API responses (like with nock ) and work both with browser calls and SSR server calls. some pseudo-code : it('loads some page (SSR mode)', () => { mockAPI.response('/some-path', {text: "some text"}); // here i configure the mock server response browser.load('/some-other-page'); // hit server for SSR response expect(myPage).toContain('some text');

How to build nock regex for dynamic urls

ぃ、小莉子 提交于 2019-12-06 07:10:08
How do i build nock configuration for the following types of urls http://example.com/harry/potter?param1=value1 and http://example.com/harry/<value1> I have two type of urls first is where i can have query params altough the base url is fixed. Second one is where base url has dynamic values. Currently i have before(function(){ nock('http://example.com') .get('/terminal/chrome_log') .reply(200, "OK"); nock('http://example.com') .get(function(uri) { return uri.indexOf('harry') >= 0; }) .reply(200, "OK"); }); Would be of great help to know something that works with node nock. You can specify path

Nock is not intercepting API call in Redux test

不羁的心 提交于 2019-12-05 04:40:06
I'm trying to test an api call in a redux app. The code pretty much follows the pattern outlined in the Async Action Creators section of the redux docs: http://redux.js.org/docs/recipes/WritingTests.html The gist of it is that you use redux-mock-store to record and assert against any actions that are triggered. This is the whole test, using nock to mock the api call: import React from 'React' import ReactDOM from 'react-dom' import expect from 'expect'; import expectJSX from 'expect-jsx'; import TestUtils from 'react-addons-test-utils' import configureMockStore from 'redux-mock-store' import

Nightwatch Mock HTTP Requests

天涯浪子 提交于 2019-12-04 12:21:04
问题 I try mocking HTTP requests with nock and other libs like sinonjs but without success. import nock from "nock" const URL = "http://localhost:8080/" const SIGN_IN_PATH = "/fake/users/sign_in.json" export const signInRequest = (status, payload = {}) => { return nock(URL).get(SIGN_IN_PATH).reply(status, payload) } - import { signInRequest } from "./../../utils/fakeRequests" const doLogin = (browser) => { return browser .url("http://localhost:8080") .waitForElementVisible('form', 1000) .setValue(

how can superagent and nock work together?

别等时光非礼了梦想. 提交于 2019-12-03 15:37:54
问题 In node.js, I have trouble making superagent and nock work together. If I use request instead of superagent, it works perfectly. Here is a simple example where superagent fails to report the mocked data: var agent = require('superagent'); var nock = require('nock'); nock('http://thefabric.com') .get('/testapi.html') .reply(200, {yes: 'it works !'}); agent .get('http://thefabric.com/testapi.html') .end(function(res){ console.log(res.text); }); the res object has no 'text' property. Something

Nightwatch Mock HTTP Requests

与世无争的帅哥 提交于 2019-12-03 07:51:28
I try mocking HTTP requests with nock and other libs like sinonjs but without success. import nock from "nock" const URL = "http://localhost:8080/" const SIGN_IN_PATH = "/fake/users/sign_in.json" export const signInRequest = (status, payload = {}) => { return nock(URL).get(SIGN_IN_PATH).reply(status, payload) } - import { signInRequest } from "./../../utils/fakeRequests" const doLogin = (browser) => { return browser .url("http://localhost:8080") .waitForElementVisible('form', 1000) .setValue('input[name=email]', 'foo@foo.com') .setValue('input[name=password]', 'somepass') .click('button[type

how can superagent and nock work together?

谁说胖子不能爱 提交于 2019-12-03 06:00:46
In node.js, I have trouble making superagent and nock work together. If I use request instead of superagent, it works perfectly. Here is a simple example where superagent fails to report the mocked data: var agent = require('superagent'); var nock = require('nock'); nock('http://thefabric.com') .get('/testapi.html') .reply(200, {yes: 'it works !'}); agent .get('http://thefabric.com/testapi.html') .end(function(res){ console.log(res.text); }); the res object has no 'text' property. Something went wrong. Now if I do the same thing using request: var request = require('request'); var nock =