Skip to content

Commit

Permalink
chore: skip tests for github actions
Browse files Browse the repository at this point in the history
conditionally skip middleware/tooBusy and utils/safeServerShutdown for
CI pipeline tests.
  • Loading branch information
commenthol committed Apr 4, 2023
1 parent 72ba26a commit 0e07ad5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"scripts": {
"all": "npm-run-all lint coverage types",
"ci": "npm run all",
"ci": "CI=true npm-run-all lint coverage types",
"changelog": "conv-changelog -t groups -o",
"coverage": "c8 npm t",
"lint": "eslint --ext js .",
Expand All @@ -34,7 +34,6 @@
"debug-level": "3.0.0"
},
"devDependencies": {
"shelljs": "^0.8.5",
"@types/node": "^18.15.3",
"c8": "^7.13.0",
"consolidate": "^0.16.0",
Expand All @@ -48,6 +47,7 @@
"handlebars": "^4.7.7",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"shelljs": "^0.8.5",
"sinon": "^15.0.2",
"supertest": "^6.3.3",
"typescript": "^5.0.2"
Expand Down
1 change: 1 addition & 0 deletions test/Router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Router', function () {
app.use(handleResBodyInit, send)
app.postHook(handleSend)
app.get('/', handler)
.get('/ignore')
.get('/async', asyncHandler)
.post('/', handler)
.post('/mix', handler, asyncHandler)
Expand Down
3 changes: 2 additions & 1 deletion test/middleware/tooBusy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import assert from 'node:assert'
import { fork } from 'node:child_process'
import { fileURLToPath } from 'node:url'
import supertest from 'supertest'
import { describeBool } from '../support/describeBool.js'

const nap = (ms = 50) => new Promise((resolve) => setTimeout(() => { resolve(ms) }, ms))

describe('middleware/tooBusy', function () {
describeBool(!process.env.CI)('middleware/tooBusy', function () {
it('shall return true with load', async function () {
const filename = fileURLToPath(new URL('./tooBusy.server.js', import.meta.url))
const child = fork(filename, ['--run-too-busy-server'])
Expand Down
13 changes: 13 additions & 0 deletions test/support/describeBool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* mocha BDD tests with boolean pre-condition
*/

const noop = () => {}

export const describeBool = (trueish) => trueish ? describe : describe.skip
describeBool.only = (trueish) => trueish ? describe.only : noop
describeBool.skip = (trueish) => describe.skip // eslint-disable-line no-unused-vars

export const itBool = (trueish) => trueish ? it : it.skip
itBool.only = (trueish) => trueish ? it.only : noop
itBool.skip = (trueish) => it.skip // eslint-disable-line no-unused-vars
3 changes: 2 additions & 1 deletion test/utils/safeServerShutdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import supertest from 'supertest'
import { safeServerShutdown } from '../../src/utils/safeServerShutdown.js'
import { certs } from '../support/index.js'
import { Http2Client } from '../support/Http2Client.js'
import { describeBool } from '../support/describeBool.js'

const sleep = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms))

Expand All @@ -22,7 +23,7 @@ const METHODS = [
'TRACE'
]

describe('utils/safeServerShutdown', function () {
describeBool(!process.env.CI)('utils/safeServerShutdown', function () {
describe('http', function () {
let server
let start
Expand Down

0 comments on commit 0e07ad5

Please sign in to comment.