Skip to content

Commit 0419e1c

Browse files
committed
Setup TEST env variable in tests
1 parent 29a5306 commit 0419e1c

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ language: node_js
22
node_js:
33
- "stable"
44
sudo: required
5-
script: "sudo $(which npm) test"
5+
script: "sudo node_modules/mocha/bin/mocha --exit"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"start": "node index.js",
8-
"test": "TEST=true mocha --exit"
8+
"test": "mocha --exit"
99
},
1010
"bin": {
1111
"serve": "./index.js"

test/test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const http = require('http')
55
const https = require('https')
66
const app = require('../index.js')
77

8+
process.env.TEST = true
9+
810
// run an external script located in the scriptPath
911
function runScript(scriptPath, args = [], background = false) {
1012
return new Promise((resolve, reject) => {
@@ -52,7 +54,7 @@ function makeRequest(path = "/", secure = false) {
5254
})
5355
}
5456

55-
let process
57+
let proc
5658

5759
// TESTS
5860
describe("Testing https-localhost", () => {
@@ -68,11 +70,11 @@ describe("Testing https-localhost", () => {
6870
it('serve static file used as standalone tool', async function () {
6971
await app.close()
7072
runScript("index.js", ["test"], true)
71-
.then(proc => process = proc)
73+
.then(process => proc = process)
7274
.catch(err => console.error(err))
7375
await sleep(500)
7476
await makeRequest("/test.html", true)
7577
.then(res => assert(res.data.toString() === fs.readFileSync("test/test.html").toString()))
76-
if (process) process.kill('SIGINT')
78+
if (proc) proc.kill('SIGINT')
7779
})
7880
})

0 commit comments

Comments
 (0)