test: fix async tests resolved in random order (#6143)

This commit is contained in:
Joshua Chen 2021-12-21 18:51:56 +08:00 committed by GitHub
parent 9078fd9fb2
commit 287292497d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 31 deletions

View file

@ -468,7 +468,7 @@ describe('simple site', () => {
test('docs with invalid id', async () => {
const {defaultTestUtils} = await loadSite();
expect(() => {
await expect(async () =>
defaultTestUtils.processDocFile(
createFakeDocFile({
source: 'some/fake/path',
@ -476,8 +476,8 @@ describe('simple site', () => {
id: 'Hello/world',
},
}),
);
}).toThrowErrorMatchingInlineSnapshot(
),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Document id \\"Hello/world\\" cannot include slash."`,
);
});
@ -485,7 +485,9 @@ describe('simple site', () => {
test('custom pagination', async () => {
const {defaultTestUtils, options, versionsMetadata} = await loadSite();
const docs = await readVersionDocs(versionsMetadata[0], options);
expect(await defaultTestUtils.generateNavigation(docs)).toMatchSnapshot();
await expect(
defaultTestUtils.generateNavigation(docs),
).resolves.toMatchSnapshot();
});
test('bad pagination', async () => {
@ -497,9 +499,9 @@ describe('simple site', () => {
frontmatter: {pagination_prev: 'nonexistent'},
}),
);
await expect(async () => {
await defaultTestUtils.generateNavigation(docs);
}).rejects.toThrowErrorMatchingInlineSnapshot(
await expect(
defaultTestUtils.generateNavigation(docs),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Error when loading hehe in .: the pagination_prev front matter points to a non-existent ID nonexistent."`,
);
});