Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Mock Service Worker #427

Merged
merged 11 commits into from
Oct 19, 2022
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ on:
jobs:
# This workflow contains a single job called "build"
build:
env:
NODE_ENV: test

# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand All @@ -25,6 +28,10 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: actions/setup-node@v1
with:
node-version: 16

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
Expand Down
40 changes: 0 additions & 40 deletions __mocks__/@octokit/rest.js

This file was deleted.

7 changes: 7 additions & 0 deletions config/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import esbuild from 'esbuild'
import * as common from './common.js'
import {unlink} from 'node:fs'
import {join} from 'node:path'


esbuild
.build(common.build)
.then((result) => {
// Remove development resources from non-development builds
if (process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'test') {
unlink(join(common.buildDir, 'mockServiceWorker.js'), (err) => console.log(err))
}

console.log('Build succeeded.')
})
.catch(() => process.exit(1))
2 changes: 1 addition & 1 deletion config/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const __dirname = path.dirname(__filename)

const entryPoint = path.resolve(__dirname, '..', 'src', 'index.jsx')
const assetsDir = path.resolve(__dirname, '..', 'public')
const buildDir = path.resolve(__dirname, '..', 'docs')
export const buildDir = path.resolve(__dirname, '..', 'docs')

export const build = {
entryPoints: [entryPoint],
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jsdom": "^20.0.0",
"msw": "^0.47.4",
"shx": "^0.3.4",
"storybook-addon-material-ui": "^0.9.0-alpha.24",
"storybook-addon-turbo-build": "^1.1.0"
},
"msw": {
"workerDirectory": "public"
}
}