Skip to content

Commit

Permalink
test: wait for 1ms for every api test
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Mar 28, 2024
1 parent 3c9ad0b commit d21bc80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
10 changes: 10 additions & 0 deletions packages/integration-tests/jest.setup.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ import { authedAdminTenantApi } from './lib/api/api.js';
await authedAdminTenantApi.patch('sign-in-exp', {
json: { signInMode: 'SignInAndRegister' },
});

const waitFor = async (ms) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});

global.afterEach(async () => {
// Try to mitigate the issue of "Socket hang up". See https://github.com/nodejs/node/issues/47130
await waitFor(1);
});
13 changes: 1 addition & 12 deletions packages/integration-tests/src/tests/api/admin-user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,10 @@ import {
import { clearConnectorsByTypes } from '#src/helpers/connector.js';
import { createUserByAdmin, expectRejects } from '#src/helpers/index.js';
import { createNewSocialUserWithUsernameAndPassword } from '#src/helpers/interactions.js';
import {
generateUsername,
generateEmail,
generatePhone,
generatePassword,
waitFor,
} from '#src/utils.js';
import { generateUsername, generateEmail, generatePhone, generatePassword } from '#src/utils.js';

const randomString = () => crypto.randomBytes(8).toString('hex');

afterEach(async () => {
// Try to mitigate the issue of "Socket hang up". See https://github.com/nodejs/node/issues/47130
await waitFor(0);
});

describe('admin console user management', () => {
beforeAll(async () => {
await clearConnectorsByTypes([ConnectorType.Social]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ import {
resetPasswordPolicy,
} from '#src/helpers/sign-in-experience.js';
import { generateNewUserProfile, generateNewUser } from '#src/helpers/user.js';
import { waitFor } from '#src/utils.js';

afterEach(async () => {
// Try to mitigate the issue of "Socket hang up". See https://github.com/nodejs/node/issues/47130
await waitFor(0);
});

describe('register with username and password', () => {
it('register with username and password', async () => {
Expand Down

0 comments on commit d21bc80

Please sign in to comment.