hatch-surf/node_modules/next/dist/trace/report/index.test.js
Riley Zhang df378d33ef
Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Merge GitHub main into Gitea repo (allow unrelated histories)
Resolved conflicts by taking GitHub versions for:
- .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml

Kept deploy.sh updated to:
- Pull from GitHub (primary source)
- Push to Gitea (push-mirror)
- Build from site/ directory (GitHub structure)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-25 05:20:46 +02:00

63 lines
2.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _promises = require("fs/promises");
const _ = require(".");
const _shared = require("../shared");
const _path = require("path");
const _os = require("os");
const TRACE_EVENT = {
name: 'test-span',
duration: 321,
timestamp: Date.now(),
id: 127,
startTime: Date.now()
};
const WEBPACK_INVALIDATED_EVENT = {
name: 'webpack-invalidated',
duration: 100,
timestamp: Date.now(),
id: 112,
startTime: Date.now()
};
describe('Trace Reporter', ()=>{
describe('JSON reporter', ()=>{
it('should write the trace events to JSON file', async ()=>{
const tmpDir = await (0, _promises.mkdtemp)((0, _path.join)((0, _os.tmpdir)(), 'json-reporter'));
(0, _shared.setGlobal)('distDir', tmpDir);
(0, _shared.setGlobal)('phase', 'anything');
_.reporter.report(TRACE_EVENT);
await _.reporter.flushAll();
const traceFilename = (0, _path.join)(tmpDir, 'trace');
const traces = JSON.parse(await (0, _promises.readFile)(traceFilename, 'utf-8'));
expect(traces.length).toEqual(1);
expect(traces[0].name).toEqual('test-span');
expect(traces[0].id).toEqual(127);
expect(traces[0].duration).toEqual(321);
expect(traces[0].traceId).toBeDefined();
});
});
describe('Telemetry reporter', ()=>{
it('should record telemetry event', async ()=>{
const recordMock = jest.fn();
const telemetryMock = {
record: recordMock
};
(0, _shared.setGlobal)('telemetry', telemetryMock);
// This should be ignored.
_.reporter.report(TRACE_EVENT);
expect(recordMock).toHaveBeenCalledTimes(0);
_.reporter.report(WEBPACK_INVALIDATED_EVENT);
expect(recordMock).toHaveBeenCalledTimes(1);
expect(recordMock).toHaveBeenCalledWith({
eventName: 'WEBPACK_INVALIDATED',
payload: {
durationInMicroseconds: 100
}
});
});
});
});
//# sourceMappingURL=index.test.js.map