diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c17a7aee..94707adb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: run: npm run build - name: Unit Test - run: npm run unit-test + run: npm run test - name: Integration Test run: npm run integration-test diff --git a/.husky/pre-push b/.husky/pre-push index ff0069d0..879e9351 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npm run unit-test +npm run test diff --git a/bin/testcafe b/bin/testcafe deleted file mode 100755 index 3a34f17f..00000000 --- a/bin/testcafe +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env node - -const { testCafeRunner } = require('../lib/console-wrapper'); - -(async () => await testCafeRunner())(); diff --git a/package-lock.json b/package-lock.json index 3f912f51..7f44f505 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,9 +24,6 @@ "xml-js": "1.6.11", "yargs": "17.7.2" }, - "bin": { - "sauce-testcafe-runner": "bin/testcafe" - }, "devDependencies": { "@babel/core": "^7.24.9", "@babel/preset-env": "^7.24.8", diff --git a/package.json b/package.json index d326f786..0d75bafb 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,12 @@ "author": "", "license": "MIT", "private": true, - "bin": "./bin/testcafe", - "main": "lib/console-wrapper.js", + "main": "lib/testcafe-runner.js", "scripts": { "build": "tsc && cp src/sauce-testcafe-config.cjs lib/", - "test": "node lib/console-wrapper.js", + "test": "jest --env node", "lint": "prettier --check '**/*.{js,ts,mjs,cjs}' && eslint .", "fmt": "prettier --write '**/*.{js,ts,mjs,cjs}'", - "unit-test": "jest --env node", "integration-test": "bash ./tests/run.sh" }, "keywords": [ diff --git a/scripts/bundle.sh b/scripts/bundle.sh index de2d53d5..cba1f830 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -3,7 +3,6 @@ rm -rf ./bundle/ mkdir ./bundle/ mkdir -p ./bundle/scripts cp -r ./src/ ./bundle/src/ -cp -r ./bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json cp tsconfig.json bundle/tsconfig.json diff --git a/src/console-wrapper.ts b/src/console-wrapper.ts deleted file mode 100644 index d17c6b6c..00000000 --- a/src/console-wrapper.ts +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env node -import fs from 'fs'; -import path from 'path'; -import * as stream from 'stream'; -import child_process from 'child_process'; -import * as utils from 'sauce-testrunner-utils'; -import { TestCafeConfig } from './type'; - -async function testCafeRunner() { - const { runCfgPath } = utils.getArgs(); - const runCfgAbsolutePath = utils.getAbsolutePath(runCfgPath); - const runCfg = await utils.loadRunConfig(runCfgAbsolutePath); - const p = new Promise((resolve, reject) => { - (runCfg as TestCafeConfig).path = runCfgPath; - const assetsPath = path.join( - path.dirname(runCfgAbsolutePath), - (runCfg as TestCafeConfig).projectPath || '.', - '__assets__', - ); - if (!fs.existsSync(assetsPath)) { - fs.mkdirSync(assetsPath); - } - const fd = fs.openSync(path.join(assetsPath, 'console.log'), 'w+', 0o644); - const ws = new stream.Writable({ - write(data: any, encoding: any, cb: any) { - fs.write(fd, data, undefined, encoding, cb); - }, - }); - - const [nodeBin] = process.argv; - const testcafeRunnerEntry = path.join(__dirname, 'testcafe-runner.js'); - const child = child_process.spawn(nodeBin, [ - testcafeRunnerEntry, - ...process.argv.slice(2), - ]); - - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - child.stdout.pipe(ws); - child.stderr.pipe(ws); - - child.on('exit', (exitCode: number) => { - fs.closeSync(fd); - if (exitCode === 0) { - resolve(); - } else { - reject(exitCode); - } - }); - }); - return await p; -} - -if (require.main === module) { - testCafeRunner() - .then(() => { - process.exit(0); - }) - .catch((err) => { - console.error(err); - process.exit(err); - }); -} - -module.exports = { testCafeRunner };