diff --git a/packages/server/src/rpc/TeamService.test.ts b/packages/server/src/rpc/TeamService.test.ts index 03a43cb..636bdec 100644 --- a/packages/server/src/rpc/TeamService.test.ts +++ b/packages/server/src/rpc/TeamService.test.ts @@ -78,7 +78,7 @@ describe('team', () => { const client = getClient() const team = await client.create({name: 'test'}) const teamId = team.id - const {userId} = await test.registerAccount('test2@user.com') + const {userId} = await test.registerAccount(test.createTestUsername(2)) await client.addUser({userId, teamId, roleId: 1}) }) }) @@ -88,7 +88,7 @@ describe('team', () => { const client = getClient() const team = await client.create({name: 'test'}) const teamId = team.id - const {userId} = await test.registerAccount('test2@user.com') + const {userId} = await test.registerAccount(test.createTestUsername(2)) await client.addUser({userId, teamId, roleId: 1}) await client.removeUser({userId, teamId, roleId: 1}) }) @@ -99,7 +99,7 @@ describe('team', () => { const client = getClient() const team = await client.create({name: 'test'}) const teamId = team.id - const {userId} = await test.registerAccount('test2@user.com') + const {userId} = await test.registerAccount(test.createTestUsername(2)) await client.addUser({userId, teamId, roleId: 1}) const {usersInTeam} = await client.findUsers(teamId) expect(usersInTeam.length).toBe(2) diff --git a/packages/server/src/test-utils/TestUtils.ts b/packages/server/src/test-utils/TestUtils.ts index 56d5cc0..a1786d1 100644 --- a/packages/server/src/test-utils/TestUtils.ts +++ b/packages/server/src/test-utils/TestUtils.ts @@ -16,7 +16,7 @@ import {Server} from 'http' import { IAppServer } from '../application/IAppServer' export class TestUtils { - readonly username = `test${process.env.JEST_WORKER_ID}@user.com` + readonly username = this.createTestUsername() readonly password = 'Password10' readonly app: IAppServer @@ -29,6 +29,10 @@ export class TestUtils { this.transactionManager = this.bootstrap.database.transactionManager } + createTestUsername(id = 1) { + return `test${process.env.JEST_WORKER_ID}_${id}@user.com` + } + /** * Set up beforeEach and afterEach cases for jest tests. Helps create and * execute the tests in transaction, and rolls it back in the end.