Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

test: retry verify tag 3 times #3395

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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