diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4520d77..bdfe840 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,8 @@ jobs: - name: Lint run: npm run lint - name: Test + env: + NODE_OPTIONS: "--max-old-space-size=8192" run: npm test - name: Report Coverage uses: codecov/codecov-action@v4.5.0 diff --git a/test/integration.js b/test/integration.js index 99376c5..99d614f 100644 --- a/test/integration.js +++ b/test/integration.js @@ -176,7 +176,7 @@ describe('duel', () => { assert.equal(statusEsm, 0) }) - it.skip('supports both builds output to directories', async t => { + it('supports both builds output to directories', async t => { const spy = t.mock.method(global.console, 'log') t.after(async () => { @@ -191,7 +191,7 @@ describe('duel', () => { assert.ok(existsSync(resolve(proDist, 'cjs/index.cjs'))) }) - it.skip('supports import attributes and ts import assertion resolution mode', async t => { + it('supports import attributes and ts import assertion resolution mode', async t => { const spy = t.mock.method(global.console, 'log') t.after(async () => { @@ -204,7 +204,7 @@ describe('duel', () => { ) }) - it.skip('works as a cli script', () => { + it('works as a cli script', () => { const resp = execSync(`${resolve('./src/duel.js')} -h`, { shell, cwd: resolve(__dirname, '..'), @@ -213,7 +213,7 @@ describe('duel', () => { assert.ok(resp.toString().indexOf('Options:') > -1) }) - it.skip('reports compilation errors during a build', async t => { + it('reports compilation errors during a build', async t => { const spy = t.mock.method(global.console, 'log') const spyExit = t.mock.method(process, 'exit') @@ -234,7 +234,7 @@ describe('duel', () => { assert.equal(spy.mock.calls[1].arguments[1], 'Compilation errors found.') }) - it.skip('reports an error when no package.json file found', async t => { + it('reports an error when no package.json file found', async t => { const spy = t.mock.method(global.console, 'log') t.after(async () => { diff --git a/test/integrationOther.js b/test/integrationOther.js new file mode 100644 index 0000000..65ca69d --- /dev/null +++ b/test/integrationOther.js @@ -0,0 +1,101 @@ +import { describe, it, before } from 'node:test' +import assert from 'node:assert/strict' +import { fileURLToPath } from 'node:url' +import { dirname, resolve, join } from 'node:path' +import { rm } from 'node:fs/promises' +import { existsSync } from 'node:fs' +import { execSync } from 'node:child_process' +import { platform } from 'node:process' + +import { duel } from '../src/duel.js' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) +const plain = resolve(__dirname, '__fixtures__/plain') +const project = resolve(__dirname, '__fixtures__/project') +const esmProject = resolve(__dirname, '__fixtures__/esmProject') +const plainDist = join(plain, 'dist') +const proDist = join(project, 'dist') +const esmDist = join(esmProject, 'dist') +const errDist = resolve(__dirname, '__fixtures__/compileErrors/dist') +const rmDist = async distPath => { + await rm(distPath, { recursive: true, force: true }) +} +const shell = platform === 'win32' + +describe('duel', () => { + before(async () => { + await rmDist(proDist) + await rmDist(esmDist) + await rmDist(errDist) + await rmDist(plainDist) + }) + + it.skip('supports both builds output to directories', async t => { + const spy = t.mock.method(global.console, 'log') + + t.after(async () => { + await rmDist(proDist) + }) + await duel(['-p', 'test/__fixtures__/project/tsconfig.json', '-k', project, '-d']) + + assert.ok( + spy.mock.calls[3].arguments[0].startsWith('Successfully created a dual CJS build'), + ) + assert.ok(existsSync(resolve(proDist, 'esm/index.js'))) + assert.ok(existsSync(resolve(proDist, 'cjs/index.cjs'))) + }) + + it.skip('supports import attributes and ts import assertion resolution mode', async t => { + const spy = t.mock.method(global.console, 'log') + + t.after(async () => { + await rmDist(plainDist) + }) + await duel(['-p', plain, '-k', plain]) + + assert.ok( + spy.mock.calls[2].arguments[0].startsWith('Successfully created a dual CJS build'), + ) + }) + + it.skip('works as a cli script', () => { + const resp = execSync(`${resolve('./src/duel.js')} -h`, { + shell, + cwd: resolve(__dirname, '..'), + }) + + assert.ok(resp.toString().indexOf('Options:') > -1) + }) + + it.skip('reports compilation errors during a build', async t => { + const spy = t.mock.method(global.console, 'log') + const spyExit = t.mock.method(process, 'exit') + + t.after(async () => { + await rmDist(errDist) + }) + spyExit.mock.mockImplementation(number => { + throw new Error(`Mocked process.exit: ${number}`) + }) + await assert.rejects( + async () => { + await duel(['-p', 'test/__fixtures__/compileErrors/tsconfig.json']) + }, + { message: /Mocked process\.exit/ }, + ) + + assert.ok(spyExit.mock.calls[0].arguments > 0) + assert.equal(spy.mock.calls[1].arguments[1], 'Compilation errors found.') + }) + + it.skip('reports an error when no package.json file found', async t => { + const spy = t.mock.method(global.console, 'log') + + t.after(async () => { + await rmDist(esmDist) + }) + await duel(['-p', 'test/__fixtures__/esmProject/tsconfig.json', '--pkg-dir', '/']) + assert.equal(spy.mock.calls[0].arguments[1], 'No package.json file found.') + }) +})