Skip to content

Commit

Permalink
move to msw .use!!
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Jun 1, 2020
1 parent faaece2 commit b733434
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 172 deletions.
141 changes: 74 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"faker": "^4.1.0",
"history": "^5.0.0-beta.5",
"match-sorter": "^4.1.0",
"msw": "^0.17.2",
"msw": "^0.18.0",
"prop-types": "^15.7.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-error-boundary": "^2.2.1",
"react-icons": "^3.10.0",
"react-query": "^1.5.3",
"react-query-devtools": "^1.1.5",
"react-query-devtools": "^1.1.16",
"react-router": "^6.0.0-alpha.5",
"react-router-dom": "^6.0.0-alpha.5",
"react-scripts": "^3.4.1",
Expand All @@ -48,7 +48,7 @@
"is-ci-cli": "^2.0.0",
"jest": "^26.0.1",
"jest-watch-typeahead": "^0.6.0",
"netlify-plugin-cypress": "^1.3.10",
"netlify-plugin-cypress": "^1.3.11",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"react-test-renderer": "^16.13.1",
Expand Down
2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Mock Service Worker.
* @see https://github.com/open-draft/msw
* @see https://github.com/mswjs/msw
* - Please do NOT modify this file.
* - Please do NOT serve this file on production.
*/
Expand Down
14 changes: 10 additions & 4 deletions src/__tests__/book-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import faker from 'faker'
import {buildBook, buildListItem} from 'test/generate'
import * as booksDB from 'test/data/books'
import * as listItemsDB from 'test/data/list-items'
import {server, rest} from 'test/server'
import {formatDate} from 'utils/misc'
import {apiURL} from 'utils/api-client'
import {App} from 'app'

async function renderBookScreen({user, book, listItem} = {}) {
Expand Down Expand Up @@ -162,10 +164,14 @@ describe('console errors', () => {
const notesTextarea = screen.getByLabelText(/notes/i)

const testErrorMessage = '__test_error_message__'
window.fetch.mockRejectedValue({
status: 500,
message: testErrorMessage,
})
server.use(
rest.put(`${apiURL}/list-items/:listItemId`, async (req, res, ctx) => {
return res(
ctx.status(400),
ctx.json({status: 400, message: testErrorMessage}),
)
}),
)

// using fake timers to skip debounce time
jest.useFakeTimers()
Expand Down
Loading

0 comments on commit b733434

Please sign in to comment.