aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/miscs
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/miscs')
-rw-r--r--shared/extra-utils/miscs/email-child-process.js2
-rw-r--r--shared/extra-utils/miscs/email.ts12
2 files changed, 9 insertions, 5 deletions
diff --git a/shared/extra-utils/miscs/email-child-process.js b/shared/extra-utils/miscs/email-child-process.js
index 40ae37d70..088a5a08c 100644
--- a/shared/extra-utils/miscs/email-child-process.js
+++ b/shared/extra-utils/miscs/email-child-process.js
@@ -6,7 +6,7 @@ process.on('message', (msg) => {
6 if (msg.start) { 6 if (msg.start) {
7 const maildev = new MailDev({ 7 const maildev = new MailDev({
8 ip: '127.0.0.1', 8 ip: '127.0.0.1',
9 smtp: 1025, 9 smtp: msg.port,
10 disableWeb: true, 10 disableWeb: true,
11 silent: true 11 silent: true
12 }) 12 })
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 }