Skip to content

Commit

Permalink
Fix test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Oct 3, 2023
1 parent b45fbf4 commit cb344b7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 29 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- run: npm ci
- run: npm run build:test
- run: npm test
48 changes: 24 additions & 24 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
"homepage": "https://github.com/auth0/nextjs-auth0#readme",
"devDependencies": {
"@edge-runtime/jest-environment": "^2.1.0",
"@edge-runtime/jest-environment": "^2.3.4",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^13.4.0",
"@testing-library/react-hooks": "^5.0.3",
Expand Down Expand Up @@ -100,7 +100,7 @@
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"expect-type": "^0.16.0",
"jest": "^29.5.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.5.0",
"jest-environment-node-single-context": "^27.3.0",
"next": "^13.4.10",
Expand Down
10 changes: 7 additions & 3 deletions tests/fixtures/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import { parse } from 'url';
import { AddressInfo } from 'net';

let server: Server;
let app: any;
let handle: any;

export const start = async (): Promise<string> => {
const app = next({ dev: false, dir: path.join(__dirname, 'test-app') });
await app.prepare();
const handle = app.getRequestHandler();
if (!app) {
app = next({ dev: false, dir: path.join(__dirname, 'test-app') });
await app.prepare();
handle = app.getRequestHandler();
}
server = createHttpServer(async (req, res) => {
const parsedUrl = parse(req.url as string, true);
await handle(req, res, parsedUrl);
Expand Down
1 change: 1 addition & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (typeof TextDecoder !== 'undefined') {
}

beforeEach(() => {
globalThis.WebSocket = globalThis.WebSocket || function () {};
jest.spyOn(console, 'warn').mockImplementation(() => {
// no-op
});
Expand Down

0 comments on commit cb344b7

Please sign in to comment.