From 8cc878ad939dd8a46cf19bca2d0b31540e9e50d8 Mon Sep 17 00:00:00 2001 From: ghe Date: Sun, 23 Apr 2023 13:45:39 +0100 Subject: [PATCH] test: wait before reading log file --- test/lib/source-handlers/gitlab/list-groups.test.ts | 2 +- test/lib/source-handlers/gitlab/list-repos.test.ts | 6 +++--- test/scripts/import-projects.test.ts | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/lib/source-handlers/gitlab/list-groups.test.ts b/test/lib/source-handlers/gitlab/list-groups.test.ts index c2147d0f..b91d3d1e 100644 --- a/test/lib/source-handlers/gitlab/list-groups.test.ts +++ b/test/lib/source-handlers/gitlab/list-groups.test.ts @@ -17,5 +17,5 @@ describe('listGitlabGroups', () => { id: expect.any(Number), url: expect.any(String), }); - }); + }, 10000); }); diff --git a/test/lib/source-handlers/gitlab/list-repos.test.ts b/test/lib/source-handlers/gitlab/list-repos.test.ts index 25157bff..cdb6d816 100644 --- a/test/lib/source-handlers/gitlab/list-repos.test.ts +++ b/test/lib/source-handlers/gitlab/list-repos.test.ts @@ -25,7 +25,7 @@ describe('listGitlabRepos', () => { expect( repos.filter((r) => r.name === `${GITLAB_ORG_NAME}/shared-with-group`), ).toHaveLength(1); - }); + }, 10000); it('list repos (Gitlab Custom URL) excludes a shared project', async () => { const GITLAB_BASE_URL = process.env.TEST_GITLAB_BASE_URL; const GITLAB_ORG_NAME = process.env.TEST_GITLAB_ORG_NAME; @@ -37,7 +37,7 @@ describe('listGitlabRepos', () => { repos.filter((r) => r.name === `${GITLAB_ORG_NAME}/shared-with-group`), ).toEqual([]); expect(repos.length > 0).toBeTruthy(); - }); + }, 10000); it('list repos for a sub-group', async () => { const GITLAB_BASE_URL = process.env.TEST_GITLAB_BASE_URL; @@ -45,5 +45,5 @@ describe('listGitlabRepos', () => { const gitlabGroupName = 'snyk-fixtures/example-sub-group'; const repos = await listGitlabRepos(gitlabGroupName, GITLAB_BASE_URL); expect(repos.length > 0).toBeTruthy(); - }); + }, 10000); }); diff --git a/test/scripts/import-projects.test.ts b/test/scripts/import-projects.test.ts index 3dba5bca..25deaf2b 100644 --- a/test/scripts/import-projects.test.ts +++ b/test/scripts/import-projects.test.ts @@ -41,6 +41,8 @@ describe('Import projects script', () => { success: true, targetFile: expect.any(String), }); + // give file a little time to be finished to be written + await new Promise((r) => setTimeout(r, 5000)); const logFile = fs.readFileSync(logFiles.importLogPath, 'utf8'); // Github project expect(logFile).toMatch( @@ -63,6 +65,8 @@ describe('Import projects script', () => { success: true, targetFile: expect.any(String), }); + // give file a little time to be finished to be written + await new Promise((r) => setTimeout(r, 5000)); const logFile = fs.readFileSync(logFiles.importLogPath, 'utf8'); // Gitlab project expect(logFile).toMatch(