aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/miscs/email.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/miscs/email.ts')
-rw-r--r--shared/extra-utils/miscs/email.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/shared/extra-utils/miscs/email.ts b/shared/extra-utils/miscs/email.ts
index f9f1bd95b..b2a1093da 100644
--- a/shared/extra-utils/miscs/email.ts
+++ b/shared/extra-utils/miscs/email.ts
@@ -1,4 +1,6 @@
1import { fork, ChildProcess } from 'child_process' 1import { ChildProcess, fork } from 'child_process'
2import { randomInt } from '../../core-utils/miscs/miscs'
3import { parallelTests } from '../server/servers'
2 4
3class MockSmtpServer { 5class MockSmtpServer {
4 6
@@ -20,7 +22,9 @@ class MockSmtpServer {
20 } 22 }
21 23
22 collectEmails (emailsCollection: object[]) { 24 collectEmails (emailsCollection: object[]) {
23 return new Promise((res, rej) => { 25 return new Promise<number>((res, rej) => {
26 const port = parallelTests() ? randomInt(1000, 2000) : 1025
27
24 if (this.started) { 28 if (this.started) {
25 this.emails = emailsCollection 29 this.emails = emailsCollection
26 return res() 30 return res()
@@ -28,7 +32,7 @@ class MockSmtpServer {
28 32
29 // ensure maildev isn't started until 33 // ensure maildev isn't started until
30 // unexpected exit can be reported to test runner 34 // unexpected exit can be reported to test runner
31 this.emailChildProcess.send({ start: true }) 35 this.emailChildProcess.send({ start: true, port })
32 this.emailChildProcess.on('exit', () => { 36 this.emailChildProcess.on('exit', () => {
33 return rej(new Error('maildev exited unexpectedly, confirm port not in use')) 37 return rej(new Error('maildev exited unexpectedly, confirm port not in use'))
34 }) 38 })
@@ -38,7 +42,7 @@ class MockSmtpServer {
38 } 42 }
39 this.started = true 43 this.started = true
40 this.emails = emailsCollection 44 this.emails = emailsCollection
41 return res() 45 return res(port)
42 }) 46 })
43 }) 47 })
44 } 48 }