Files
klz-cables.com/.pnpm-store/v10/files/cb/cbd239ffece75a70b78f82e5a232782c9918ebc91c81b7dc5562f78d39f1d63be1580072784ed4896941487ceb07c171eb3d5a052154a08f89293922c05d54
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

47 lines
1.4 KiB
Plaintext

'use strict'
const { test } = require('tap')
const config = require('./pkg.config.json')
const { promisify } = require('util')
const { unlink } = require('fs/promises')
const { join } = require('path')
const { platform } = require('process')
const exec = promisify(require('child_process').exec)
test('worker test when packaged into executable using pkg', async (t) => {
const packageName = 'index'
// package the app into several node versions, check config for more info
const filePath = `${join(__dirname, packageName)}.js`
const configPath = join(__dirname, 'pkg.config.json')
process.env.NODE_OPTIONS ||= ''
process.env.NODE_OPTIONS = '--no-warnings'
const { stderr } = await exec(`npx pkg ${filePath} --config ${configPath}`)
// there should be no error when packaging
t.equal(stderr, '')
// pkg outputs files in the following format by default: {filename}-{node version}
for (const target of config.pkg.targets) {
// execute the packaged test
let executablePath = `${join(config.pkg.outputPath, packageName)}-${target}`
// when on windows, we need the .exe extension
if (platform === 'win32') {
executablePath = `${executablePath}.exe`
} else {
executablePath = `./${executablePath}`
}
const { stderr } = await exec(executablePath)
// check if there were no errors
t.equal(stderr, '')
// clean up afterwards
await unlink(executablePath)
}
t.end()
})