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

chore: add test for NODE_ENV in server process for #184 #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"pretty": "prettier-standard 'src/**/*.js'",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
"test": "npm run unit",
"unit": "mocha src/*-spec.js",
"unit": "mocha --timeout 30000 'src/*-spec.js' 'test/*spec.js'",
"unused-deps": "dependency-check --unused --no-dev .",
"semantic-release": "semantic-release",
"start": "node test/server.js",
Expand Down Expand Up @@ -97,6 +97,7 @@
"dependency-check": "3.4.1",
"deps-ok": "1.4.1",
"dont-crack": "1.2.1",
"execa-wrap": "1.4.0",
"git-issues": "1.3.1",
"got": "9.6.0",
"license-checker": "24.1.0",
Expand Down
24 changes: 24 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-env mocha */
const la = require('lazy-ass')
const execaWrap = require('execa-wrap')
const path = require('path')

describe('test-node-env', () => {
// for https://github.com/bahmutov/start-server-and-test/issues/184
it('passes NODE_ENV to the server process', () => {
const cwd = path.join(__dirname, 'test-node-env')
return execaWrap('npm', ['run', 'demo'], {
env: {
NODE_ENV: 'test'
},
cwd,
filter: ['stdout']
}).then(result => {
la(
result.includes('server has NODE_ENV=test'),
'result does not pass the right NODE_ENV to the server process',
result
)
})
})
})
8 changes: 8 additions & 0 deletions test/test-node-env/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "test-node-env",
"scripts": {
"start": "node ../server",
"test": "echo server has NODE_ENV=$NODE_ENV",
"demo": "node ../../src/bin/start.js 9000"
}
}