Skip to content

Commit

Permalink
test: retry verify tag 3 times (#3395)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Feb 12, 2025
1 parent b9a12f5 commit e28273f
Showing 1 changed file with 54 additions and 40 deletions.
94 changes: 54 additions & 40 deletions test/scripts/apidocs/verify-jsdoc-tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,54 +164,68 @@ ${examples}`;
assertDescription(signature.description);
});

it('verify @example tag', { timeout: 30000 }, async () => {
const examples = signature.examples.join('\n');

expect(
examples,
`${moduleName}.${methodName} to have examples`
).not.toBe('');

// Grab path to example file
const path = resolvePathToMethodFile(
moduleName,
methodName,
signatureIndex
);
it(
'verify @example tag',
{
retry: 3,
timeout: 30000,
},
async () => {
const examples = signature.examples.join('\n');

expect(
examples,
`${moduleName}.${methodName} to have examples`
).not.toBe('');

// Grab path to example file
const path = resolvePathToMethodFile(
moduleName,
methodName,
signatureIndex
);

// Executing the examples should not throw
await expect(
import(`${path}?scope=example`),
examples
).resolves.toBeDefined();
});
// Executing the examples should not throw
await expect(
import(`${path}?scope=example`),
examples
).resolves.toBeDefined();
}
);

// This only checks whether the whole method is deprecated or not
// It does not check whether the method is deprecated for a specific set of arguments
it('verify @deprecated tag', { timeout: 30000 }, async () => {
// Grab path to example file
const path = resolvePathToMethodFile(
moduleName,
methodName,
signatureIndex
);
it(
'verify @deprecated tag',
{
retry: 3,
timeout: 30000,
},
async () => {
// Grab path to example file
const path = resolvePathToMethodFile(
moduleName,
methodName,
signatureIndex
);

const consoleWarnSpy = vi.spyOn(console, 'warn');
const consoleWarnSpy = vi.spyOn(console, 'warn');

// Run the examples
await import(`${path}?scope=deprecated`);
// Run the examples
await import(`${path}?scope=deprecated`);

// Verify that deprecated methods log a warning
const { deprecated } = signature;
if (deprecated == null) {
expect(consoleWarnSpy).not.toHaveBeenCalled();
} else {
expect(consoleWarnSpy).toHaveBeenCalled();
expect(deprecated).not.toBe('');
}
// Verify that deprecated methods log a warning
const { deprecated } = signature;
if (deprecated == null) {
expect(consoleWarnSpy).not.toHaveBeenCalled();
} else {
expect(consoleWarnSpy).toHaveBeenCalled();
expect(deprecated).not.toBe('');
}

consoleWarnSpy.mockRestore();
});
consoleWarnSpy.mockRestore();
}
);

describe.each(signature.parameters.map((p) => [p.name, p]))(
'%s',
Expand Down

0 comments on commit e28273f

Please # to comment.