Skip to content

Commit

Permalink
Uses "Node.js" over "NodeJS"
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Feb 26, 2021
1 parent 4d90221 commit e46fc81
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/02-not_intercepted_in_node.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: 'Issue: NodeJS interception'
about: My request is not intercepted/mocked in NodeJS (tests)
name: 'Issue: Node.js interception'
about: My request is not intercepted/mocked in Node.js (tests)
title: ''
labels: bug, scope:node
assignees: ''
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ Performing a `GET https://github.com/octocat` request in your application will r
## Node

- [Learn more about the NodeJS integration](https://mswjs.io/docs/getting-started/integrate/node)
- [Learn more about the Node.js integration](https://mswjs.io/docs/getting-started/integrate/node)
- [`setupServer` API](https://mswjs.io/docs/api/setup-server)

### How does it work?

Although Service Worker is a browser-specific API, this library allows to reuse the same mock definition to have API mocking in NodeJS through augmenting native request issuing modules.
Although Service Worker is a browser-specific API, this library allows to reuse the same mock definition to have API mocking in Node.js through augmenting native request issuing modules.

### How is it different?

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "msw",
"version": "0.27.0",
"description": "Seamless REST/GraphQL API mocking library for browser and Node.",
"description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
"main": "lib/umd/index.js",
"module": "lib/esm/index.js",
"types": "lib/types/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const buildUmd = {
}

/**
* Configuration for the NodeJS (CJS) build.
* Configuration for the Node.js (CJS) build.
*/
const buildNode = {
input: 'src/node/index.ts',
Expand All @@ -81,7 +81,7 @@ const buildNode = {
'timers',
'node-request-interceptor',
/**
* Exclude NodeJS request interceptors from being compiled.
* Exclude Node.js request interceptors from being compiled.
* @see https://github.com/mswjs/node-request-interceptor/issues/52
*/
'node-request-interceptor/lib/interceptors/ClientRequest',
Expand Down Expand Up @@ -123,7 +123,7 @@ const buildNative = {
'events',
'node-request-interceptor',
/**
* Exclude NodeJS request interceptors from being compiled.
* Exclude Node.js request interceptors from being compiled.
* @see https://github.com/mswjs/node-request-interceptor/issues/52
*/
'node-request-interceptor/lib/interceptors/ClientRequest',
Expand Down
2 changes: 1 addition & 1 deletion src/context/delay.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { delay, NODE_SERVER_RESPONSE_TIME } from './delay'
import { response } from '../response'

test('sets a NodeJS-specific response delay when not provided', async () => {
test('sets a Node.js-specific response delay when not provided', async () => {
const resolvedResponse = await response(delay())
expect(resolvedResponse).toHaveProperty('delay', NODE_SERVER_RESPONSE_TIME)
})
Expand Down
4 changes: 2 additions & 2 deletions src/context/delay.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @jest-environment jsdom
*
* Since jsdom also runs in NodeJS, expect a NodeJS-specific implicit delay.
* Since jsdom also runs in Node.js, expect a Node.js-specific implicit delay.
*/
import { delay, NODE_SERVER_RESPONSE_TIME } from './delay'
import { response } from '../response'

test('sets a NodeJS-specific response delay when not provided', async () => {
test('sets a Node.js-specific response delay when not provided', async () => {
const resolvedResponse = await response(delay())
expect(resolvedResponse).toHaveProperty('delay', NODE_SERVER_RESPONSE_TIME)
})
Expand Down
4 changes: 2 additions & 2 deletions src/node/createSetupServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function createSetupServer(...interceptors: Interceptor[]) {
// Error when attempting to run this function in a browser environment.
if (!isNodeProcess()) {
throw new Error(
'[MSW] Failed to execute `setupServer` in the environment that is not NodeJS (i.e. a browser). Consider using `setupWorker` instead.',
'[MSW] Failed to execute `setupServer` in the environment that is not Node.js (i.e. a browser). Consider using `setupWorker` instead.',
)
}

Expand Down Expand Up @@ -108,7 +108,7 @@ export function createSetupServer(...interceptors: Interceptor[]) {

if (requestCookieString) {
// Set mocked request cookies from the `cookie` header of the original request.
// No need to take `credentials` into account, because in NodeJS requests are intercepted
// No need to take `credentials` into account, because in Node.js requests are intercepted
// _after_ they happen. Request issuer should have already taken care of sending relevant cookies.
// Unlike browser, where interception is on the worker level, _before_ the request happens.
mockedRequest.cookies = cookieUtils.parse(requestCookieString)
Expand Down
2 changes: 1 addition & 1 deletion src/node/setupServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { interceptXMLHttpRequest } from 'node-request-interceptor/lib/intercepto
import { createSetupServer } from './createSetupServer'

/**
* Sets up a requests interception in NodeJS with the given request handlers.
* Sets up a requests interception in Node.js with the given request handlers.
* @param {RequestHandler[]} requestHandlers List of request handlers.
* @see {@link https://mswjs.io/docs/api/setup-server `setupServer`}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/setupWorker/setupWorker.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { setupWorker } from './setupWorker'

test('returns an error when run in a NodeJS environment', () => {
test('returns an error when run in a Node.js environment', () => {
expect(setupWorker).toThrow(
'[MSW] Failed to execute `setupWorker` in a non-browser environment',
)
Expand Down
4 changes: 2 additions & 2 deletions src/setupWorker/setupWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ export function setupWorker(
},
}

// Error when attempting to run this function in a NodeJS environment.
// Error when attempting to run this function in a Node.js environment.
if (isNodeProcess()) {
throw new Error(
'[MSW] Failed to execute `setupWorker` in a non-browser environment. Consider using `setupServer` for NodeJS environment instead.',
'[MSW] Failed to execute `setupWorker` in a non-browser environment. Consider using `setupServer` for Node.js environment instead.',
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/internal/isNodeProcess.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
*/
import { isNodeProcess } from './isNodeProcess'

test('returns true when run in a NodeJS process', () => {
test('returns true when run in a Node.js process', () => {
expect(isNodeProcess()).toBe(true)
})
2 changes: 1 addition & 1 deletion src/utils/internal/isNodeProcess.react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ afterAll(() => {
global.navigator = originalNavigator
})

test('treats React Native as a NodeJS environment', () => {
test('treats React Native as a Node.js environment', () => {
expect(isNodeProcess()).toBe(true)
})
2 changes: 1 addition & 1 deletion src/utils/internal/isNodeProcess.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Returns a boolean indicating if the current process is running in NodeJS environment.
* Returns a boolean indicating if the current process is running in Node.js environment.
* @see https://github.com/mswjs/msw/pull/255
*/
export function isNodeProcess() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request/getRequestCookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getAllCookies() {
*/
export function getRequestCookies(request: MockedRequest) {
/**
* @note No cookies persist on the document in NodeJS: no document.
* @note No cookies persist on the document in Node.js: no document.
*/
if (typeof location === 'undefined') {
return {}
Expand Down

0 comments on commit e46fc81

Please sign in to comment.