示例工程 31-tsconfig-build-pipeline

31-tsconfig-build-pipeline/02-noemit-on-error/main.test.mjs

javascript · 0.6 KB

运行:31 · noemit-on-error

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { run } from './dist/main.js';
 
const here = dirname(fileURLToPath(import.meta.url));
 
test('noEmitOnError 决定类型错误时是否落盘', () => {
  assert.deepEqual(run(), []);
  assert.equal(existsSync(join(here, 'dist-fail-strict', 'demo', 'type-error.js')), false, '严格配置不产出');
  assert.equal(existsSync(join(here, 'dist-fail-emit', 'demo', 'type-error.js')), true, '关闭后仍产出');
});