I'm trying to run a simple jest setup on kubernetes. Until now it works fine on my local workstation (WLS2 on WIN10).
PROBLEM: When I add a globalTeardown
to my package.json, the function fails in my kubernetes workload, but works when executed locally. Both of the runs are invoked by npm run test
The log of the kubernetes workload prints this error:
[...] // Tests are executed as usual
Test Suites: 1 failed, 1 total
Tests: 2 failed, 1 passed, 3 total
Snapshots: 0 total
Time: 6.57s
📦 reporter is created on: /opt/app/public/report.html
node:events:505
throw er; // Unhandled 'error' event
^
Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
spawnargs: [
'-NoProfile',
'-NonInteractive',
'–ExecutionPolicy',
'Bypass',
'-EncodedCommand',
'UwB0AGEAcgB0ACAAIgAvAG8AcAB0AC8AYQBwAHAALwBwAHUAYgBsAGkAYwAvAHIAZQBwAG8AcgB0AC4AaAB0AG0AbAAiAA=='
]
}
I have no idea how this can be connected to Powershell, as the used image is based in Ubuntu. Could it be an caused by using Rancher Desktop integrated to WSL2?
package.json
{
"name": "endpoint-testing",
"version": "1.0.0",
"description": "Test utility for testing endpoints of backends from a kubernetes cluster",
"main": "index.js",
"type": "module",
"scripts": {
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --forceExit",
"watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
"run": "node --experimental-vm-modules index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.27.2",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"express-fileupload": "^1.3.1",
"form-data": "^4.0.0",
"jest": "^28.1.0",
"jest-html-reporter": "^3.5.0",
"jest-html-reporters": "^3.0.7",
"jest-standard-reporter": "^2.0.0",
"supertest": "^6.2.3",
"winston": "^3.7.2"
},
"jest": {
"globalSetup": "./tests/setup.js",
"globalTeardown": "./tests/customTeardown.js",
"reporters": [
"jest-standard-reporter",
[
"jest-html-reporters",
{
"publicPath": "./public",
"filename": "report.html",
"openReport": true,
"inlineSource": true
}
]
]
}
}
./tests/customTeardown.js
export default async function () {
console.log("Done");
};
Update:
I found this not to happen, when using Kind instead of Rancher Desktop. So this seems to be an integration issue of Rancher Desktop.