Skip to content
Merged
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
7 changes: 4 additions & 3 deletions e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { createFetch } = require('@adobe/aio-lib-core-networking')
const fetch = createFetch()
const https = require('node:https')
const { DEV_API_PREFIX, DEV_API_WEB_PREFIX } = require('../src/lib/constants')
const treeKill = require('tree-kill')

jest.unmock('execa')
jest.setTimeout(30000)
Expand Down Expand Up @@ -126,9 +127,9 @@ describe('http api tests', () => {

afterAll(() => {
if (E2E_CDN_HOST === 'localhost') {
console.log(`killed server at port ${E2E_PORT}:`, serverProcess?.kill?.('SIGTERM', {
forceKillAfterTimeout: 2000
}))
// we use tree-kill to solve the issue on Windows where grand-child processes are not killed (via node's child_process)
// the module uses OS specific processes to find all related pids and kill them
return new Promise((resolve) => treeKill(serverProcess.pid, 'SIGTERM', resolve))
}
})

Expand Down
17 changes: 17 additions & 0 deletions e2e/jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

module.exports = {
testEnvironment: 'node',
testRegex: './e2e/e2e.js',
setupFilesAfterEnv: ['./jest.e2e.setup.js']
}
24 changes: 24 additions & 0 deletions e2e/jest.e2e.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

const { stdout, stderr } = require('stdout-stderr')

jest.setTimeout(30000)

// trap console log
beforeEach(() => {
stdout.start()
stderr.start()
// change this if you need to see logs from stdout
stdout.print = true
})
afterEach(() => { stdout.stop(); stderr.stop() })
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"eslint-plugin-promise": "^6.1.1",
"jest": "^29",
"oclif": "^3.2.0",
"stdout-stderr": "^0.1.13"
"stdout-stderr": "^0.1.13",
"tree-kill": "^1.2.2"
},
"engines": {
"node": ">=18"
Expand Down Expand Up @@ -76,6 +77,6 @@
"prepack": "oclif manifest && oclif readme --no-aliases",
"postpack": "rm -f oclif.manifest.json",
"version": "oclif readme && git add README.md",
"e2e": "jest --collectCoverage=false --testRegex './e2e/e2e.js'"
"e2e": "jest --detectOpenHandles -c e2e/jest.e2e.config.js"
}
}