Skip to content

Commit

Permalink
fix: flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
doc-han committed Dec 4, 2024
1 parent cc070a6 commit d581501
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions packages/cli/test/docgen/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,29 @@ const loadJSON = async (path: string) => {
};

// Mock doc gen function
const mockGen: DocGenFn = async () => ({
namespaces: [{ type: 'namespace', name: 'smth' }],
name: 'test',
version: '1.0.0',
functions: [
{
name: 'fn',
description: 'a function',
isOperation: true,
magic: false,
parameters: [],
examples: [],
type: 'function',
},
],
});
const mockGen: DocGenFn = async () =>
new Promise((resolve) => {
setTimeout(
() =>
resolve({
namespaces: [{ type: 'namespace', name: 'smth' }],
name: 'test',
version: '1.0.0',
functions: [
{
name: 'fn',
description: 'a function',
isOperation: true,
magic: false,
parameters: [],
examples: [],
type: 'function',
},
],
}),
100
);
});

const specifier = '[email protected]';

Expand Down Expand Up @@ -148,7 +155,7 @@ test.serial(
const promise = docsHandler(options, logger, mockGen);
// the placeholder should already be created

const placeholder = JSON.parse(readFileSync(path, 'utf8'));
const placeholder = JSON.parse(readFileSync(path, 'utf-8'));
t.truthy(placeholder);
t.true(placeholder.loading);
t.assert(typeof placeholder.timestamp === 'number');
Expand Down

0 comments on commit d581501

Please sign in to comment.