Skip to content

Commit

Permalink
test: restore, use shell for mono.
Browse files Browse the repository at this point in the history
  • Loading branch information
knightedcodemonkey committed Sep 30, 2024
1 parent 96daa87 commit 895defc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
28 changes: 14 additions & 14 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ describe('duel', () => {
await rmDist(plainDist)
})

it.skip('prints options help', async t => {
it('prints options help', async t => {
const spy = t.mock.method(global.console, 'log')

await duel(['--help'])
assert.ok(spy.mock.calls[1].arguments[0].startsWith('Options:'))
})

it.skip('reports errors when passing invalid options', async t => {
it('reports errors when passing invalid options', async t => {
const spy = t.mock.method(global.console, 'log')

await duel(['--invalid'])
assert.equal(spy.mock.calls[0].arguments[1], "Unknown option '--invalid'")
})

it.skip('uses default --project value of "tsconfig.json"', async t => {
it('uses default --project value of "tsconfig.json"', async t => {
const spy = t.mock.method(global.console, 'log')
const tsConfigPath = resolve('./tsconfig.json')
const tsConfigPathTemp = tsConfigPath.replace('tsconfig', 'tsconfig.temp')
Expand All @@ -59,21 +59,21 @@ describe('duel', () => {
await rename(tsConfigPathTemp, tsConfigPath)
})

it.skip('reports errors when --project is a directory with no tsconfig.json', async t => {
it('reports errors when --project is a directory with no tsconfig.json', async t => {
const spy = t.mock.method(global.console, 'log')

await duel(['-p', 'test/__fixtures__'])
assert.ok(spy.mock.calls[0].arguments[1].endsWith('no tsconfig.json.'))
})

it.skip('reports errors when --project is not valid json', async t => {
it('reports errors when --project is not valid json', async t => {
const spy = t.mock.method(global.console, 'log')

await duel(['-p', 'test/__fixtures__/esmProject/tsconfig.not.json'])
assert.ok(spy.mock.calls[0].arguments[1].endsWith('not parsable as JSONC.'))
})

it.skip('reports errors when using deprecated --target-extension', async t => {
it('reports errors when using deprecated --target-extension', async t => {
const spy = t.mock.method(global.console, 'log')

await duel(['-x', '.mjs'])
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('duel', () => {
assert.equal(statusCjs, 0)
})

it.skip('creates a dual ESM build while transforming module globals', async t => {
it('creates a dual ESM build while transforming module globals', async t => {
const spy = t.mock.method(global.console, 'log')

t.after(async () => {
Expand Down Expand Up @@ -165,18 +165,18 @@ describe('duel', () => {
const { status: statusCjs } = spawnSync(
'node',
['test/__fixtures__/cjsProject/dist/index.js'],
{ stdio: 'inherit' },
{ shell, stdio: 'inherit' },
)
assert.equal(statusCjs, 0)
const { status: statusEsm } = spawnSync(
'node',
['test/__fixtures__/cjsProject/dist/esm/index.mjs'],
{ stdio: 'inherit' },
{ shell, stdio: 'inherit' },
)
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 () => {
Expand All @@ -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 () => {
Expand All @@ -204,15 +204,15 @@ describe('duel', () => {
)
})

it.skip('works as a cli script', () => {
it('works as a cli script', () => {
const resp = execSync(`${resolve('./src/duel.js')} -h`, {
cwd: resolve(__dirname, '..'),
})

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')

Expand All @@ -233,7 +233,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 () => {
Expand Down
10 changes: 7 additions & 3 deletions test/monorepos.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import assert from 'node:assert/strict'
import { resolve, join } from 'node:path'
import { rm } from 'node:fs/promises'
import { spawnSync } from 'node:child_process'
import { platform } from 'node:process'

import { duel } from '../src/duel.js'

const fixtures = resolve(import.meta.dirname, '__fixtures__')
const npm = join(fixtures, 'mononpm')
const npmOne = join(npm, 'one')
const npmTwo = join(npm, 'two')
const shell = platform === 'win32'
const rmDist = async distPath => {
await rm(distPath, { recursive: true, force: true })
}
Expand All @@ -26,31 +28,33 @@ describe('duel monorepos', () => {
await rmDist(join(npmTwo, 'dist'))
})

spawnSync('npm', ['install'], { cwd: npm })
spawnSync('npm', ['install'], { shell, cwd: npm })

// Build the packages (dependency first)
await duel(['-p', npmTwo, '-k', npmTwo, '-m'])
await duel(['-p', npmOne, '-k', npmOne, '-m'])

// Check for runtime errors against Node.js
const { status: twoEsm } = spawnSync('node', [join(npmTwo, 'dist', 'file.js')], {
shell,
stdio: 'inherit',
})
assert.equal(twoEsm, 0)
const { status: twoCjs } = spawnSync(
'node',
[join(npmTwo, 'dist', 'cjs', 'file.cjs')],
{ stdio: 'inherit' },
{ shell, stdio: 'inherit' },
)
assert.equal(twoCjs, 0)
const { status: oneEsm } = spawnSync('node', [join(npmOne, 'dist', 'main.js')], {
shell,
stdio: 'inherit',
})
assert.equal(oneEsm, 0)
const { status: oneCjs } = spawnSync(
'node',
[join(npmOne, 'dist', 'cjs', 'main.cjs')],
{ stdio: 'inherit' },
{ shell, stdio: 'inherit' },
)
assert.equal(oneCjs, 0)
})
Expand Down

0 comments on commit 895defc

Please sign in to comment.