Skip to content

Commit

Permalink
kill the tunnel process after tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mukesh-lt committed Jun 20, 2023
1 parent 6ff865a commit 7ffbd17
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,4 @@ libs/dexie-cloud-common/tsconfig.tsbuildinfo

#lambdatest tunnel binary
.lambdatest
tunnel.pid
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"test:unit": "karma start test/karma.conf.js --single-run",
"test:typings": "tsc -p test/typings-test/",
"test:debug": "karma start test/karma.conf.js --log-level debug",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test:unit && exit",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test:unit && (kill $(cat tunnel.pid) || exit 0)",
"test:ltTunnel": "node test/lt-local"
},
"just-build": {
Expand Down
4 changes: 2 additions & 2 deletions test/lt-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable no-console */

'use strict'

const process = require('node:process')
const lambdaTunnel = require('@lambdatest/node-tunnel')
const fs = require('fs');

const tunnelInstance = new lambdaTunnel() // eslint-disable-line new-cap
const tunnelArguments = {
Expand All @@ -13,12 +13,12 @@ const tunnelArguments = {
tunnelName: process.env.LT_TUNNEL_NAME || 'jasmine',
logFile: 'local.log'
}

if (process.env.LAMBDATEST === 'true') {
(async () => {
try {
await tunnelInstance.start(tunnelArguments)
await new Promise(res => setTimeout(res, 5000))
await fs.writeFileSync('tunnel.pid', tunnelInstance.proc.pid.toString());
} catch (error) {
console.log(error.message)
}
Expand Down

0 comments on commit 7ffbd17

Please sign in to comment.