mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Move msw listener to file
This commit is contained in:
parent
21c7b84747
commit
e54c0cdac1
2 changed files with 19 additions and 16 deletions
|
|
@ -15,23 +15,9 @@
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
import { getApiUrl } from '~/helpers/url.js'
|
import { getApiUrl } from '~/helpers/url.js'
|
||||||
import { mswServer } from '~/test/msw/server.js'
|
|
||||||
|
|
||||||
|
// Use msw
|
||||||
const mswEnabled = process.env.NODE_ENV && [ 'development', 'test' ].includes( process.env.NODE_ENV )
|
import '~/test/msw/use.js'
|
||||||
|
|
||||||
// Inspired by https://github.com/wwdrew/examples/blob/react-native/examples/react-native/index.js
|
|
||||||
if ( mswEnabled ) {
|
|
||||||
// const { native } = require( '~/test/msw/native' )
|
|
||||||
// const { mswServer } = await import( '~/test/msw/server' )
|
|
||||||
|
|
||||||
// console.log({ mswServer })
|
|
||||||
|
|
||||||
mswServer.listen( {
|
|
||||||
// Fixes issue with MSW capturing POST http://192.168.1.90:19000/symbolicate
|
|
||||||
onUnhandledRequest: 'bypass',
|
|
||||||
} )
|
|
||||||
}
|
|
||||||
|
|
||||||
// const defaultFetchMethod = (...args) => console.log(...args) // mock
|
// const defaultFetchMethod = (...args) => console.log(...args) // mock
|
||||||
|
|
||||||
|
|
|
||||||
17
test/msw/use.js
Normal file
17
test/msw/use.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { mswServer } from '~/test/msw/server.js'
|
||||||
|
|
||||||
|
|
||||||
|
const mswEnabled = process.env.NODE_ENV && [ 'development', 'test' ].includes( process.env.NODE_ENV )
|
||||||
|
|
||||||
|
// Inspired by https://github.com/wwdrew/examples/blob/react-native/examples/react-native/index.js
|
||||||
|
if ( mswEnabled ) {
|
||||||
|
// const { native } = require( '~/test/msw/native' )
|
||||||
|
// const { mswServer } = await import( '~/test/msw/server' )
|
||||||
|
|
||||||
|
// console.log({ mswServer })
|
||||||
|
|
||||||
|
mswServer.listen( {
|
||||||
|
// Fixes issue with MSW capturing POST http://192.168.1.90:19000/symbolicate
|
||||||
|
onUnhandledRequest: 'bypass',
|
||||||
|
} )
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue