diff --git a/test/fixtures/cyclical-a.mjs b/test/fixtures/cyclical-a.mjs index e69de29..763a05f 100644 --- a/test/fixtures/cyclical-a.mjs +++ b/test/fixtures/cyclical-a.mjs @@ -0,0 +1,7 @@ +import { testB } from './cyclical-b.mjs'; + +export function testA() { + console.log("testA"); +} + +testB(); diff --git a/test/fixtures/cyclical-b.mjs b/test/fixtures/cyclical-b.mjs index c816a96..1f57523 100644 --- a/test/fixtures/cyclical-b.mjs +++ b/test/fixtures/cyclical-b.mjs @@ -1,7 +1,6 @@ -import { testB } from './b.mjs'; +import { testA } from './cyclical-a.mjs'; -export function testA() { - console.log("testA"); -} - -testB(); \ No newline at end of file +export function testB() { + console.log("testB"); + testA(); +} \ No newline at end of file diff --git a/test/other/assert-cyclical-dependency-failure.mjs b/test/other/assert-cyclical-dependency-failure.mjs index 2004c0e..7ab6efc 100644 --- a/test/other/assert-cyclical-dependency-failure.mjs +++ b/test/other/assert-cyclical-dependency-failure.mjs @@ -8,13 +8,12 @@ import { strictEqual } from 'assert' const nodeProcess = spawn('node', [ '--loader', './hook.mjs', - './test/fixtures/a.mjs' + './test/fixtures/cyclical-a.mjs' ]) -// expected output is 'testB\ntestA' but the actual output of this test is '' because -// the hook fails when running against files with cylical dependencies +// expected output should be 'testB\ntestA' but the hook fails when running against files +// with cylical dependencies const expectedOutput = 'testB\ntestA' -const actualOutput = '' let stdout = '' let stderr = '' @@ -27,6 +26,6 @@ nodeProcess.stderr.on('data', (data) => { }); nodeProcess.on('close', (code) => { - strictEqual(stderr, '', 'There should be no errors on stderr') - strictEqual(stdout.trim(), actualOutput, 'The stdout should match the expected output') + // assert that the hook fails with a non-zero exit code + strictEqual(code, 1) }); \ No newline at end of file