项目文件夹

文件
Nikolay Vitkov 71e5c59bc9 test: fail if file does not exist (#2369)
Given we run test locally and that this does not change often one can
just run the command once in a while to fix the local setup.

```sh
Failed tests:

✖ matches snapshot if exists (0.78188ms)
  Error: THIRD_PARTY_NOTICES does not exist, run `npm ci && npm run bundle`
      at TestContext.<anonymous> (file:///usr/local/google/home/nvitkov/chrome-devtools-mcp/build/tests/third_party_notices.test.js:13:19)
      at Test.runInAsyncScope (node:async_hooks:227:14)
      at Test.run (node:internal/test_runner/test:1325:25)
      at Test.start (node:internal/test_runner/test:1191:17)
      at node:internal/test_runner/test:1792:71
      at node:internal/per_context/primordials:466:82
      at new Promise (<anonymous>)
      at new SafePromise (node:internal/per_context/primordials:435:3)
      at node:internal/per_context/primordials:466:9
      at Array.map (<anonymous>)
✖ THIRD_PARTY_NOTICES (1.41613ms)
  '1 subtest failed'
  
 ```
2026-07-20 08:59:49 +00:00

29 行
761 B
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import fs from 'node:fs';
import path from 'node:path';
import {describe, it} from 'node:test';
describe('THIRD_PARTY_NOTICES', () => {
it('matches snapshot', t => {
const noticesPath = path.join(
process.cwd(),
'build/src/third_party/THIRD_PARTY_NOTICES',
);
if (!fs.existsSync(noticesPath)) {
throw new Error(
'THIRD_PARTY_NOTICES does not exist, run `npm ci && npm run bundle`',
);
}
const content = fs.readFileSync(noticesPath, 'utf-8');
const normalizedContent = content
.replace(/^Version: .*$/gm, 'Version: <VERSION>')
.replaceAll('\r', '');
t.assert.snapshot(normalizedContent);
});
});