Skip to content

Commit

Permalink
Attempt to fix jest exiting too soon
Browse files Browse the repository at this point in the history
  • Loading branch information
hexrcs committed Nov 27, 2018
1 parent b16a3d1 commit 8954510
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/gatsby-remark-katex/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ describe(`remark katex plugin`, () => {
it(`doesn't crash when there's an error in development mode`, () => {
const equation = `$a^2 + b^2 = c^$`
let remark = new Remark()
const realProcess = process
const exitMock = jest.fn()
global.process = { ...realProcess, exit: exitMock }

expect(() => {
for (let parserPlugins of plugin.setParserPlugins()) {
Expand All @@ -48,11 +51,15 @@ describe(`remark katex plugin`, () => {
const markdownAST = remark.parse(equation)
plugin({ markdownAST, reporter })
}).not.toThrow()
global.process = realProcess
})

it(`crashes when there's an error in build mode`, () => {
const equation = `$a^2 + b^2 = c^$`
let remark = new Remark()
const realProcess = process
const exitMock = jest.fn()
global.process = { ...realProcess, exit: exitMock }

expect(() => {
for (let parserPlugins of plugin.setParserPlugins()) {
Expand All @@ -62,5 +69,6 @@ describe(`remark katex plugin`, () => {
const markdownAST = remark.parse(equation)
plugin({ markdownAST, reporter })
}).toThrow()
global.process = realProcess
})
})

0 comments on commit 8954510

Please sign in to comment.