Skip to content

Commit 9b769b2

Browse files
test: resolve port conflicts in translation tests
Use port 3001 for translator_spec.js instead of 3000 to avoid conflicts with translations_spec.js when running tests simultaneously.
1 parent b37781a commit 9b769b2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/unit/classes/translator_spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const express = require("express");
1010
*/
1111
function createTranslationTestEnvironment () {
1212
const translatorJs = fs.readFileSync(path.join(__dirname, "..", "..", "..", "js", "translator.js"), "utf-8");
13-
const dom = new JSDOM("", { url: "http://localhost:3000", runScripts: "outside-only" });
13+
const dom = new JSDOM("", { url: "http://localhost:3001", runScripts: "outside-only" });
1414

1515
dom.window.Log = { log: jest.fn(), error: jest.fn() };
1616
dom.window.eval(translatorJs);
@@ -32,7 +32,7 @@ describe("Translator", () => {
3232
});
3333
app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "mocks")));
3434

35-
server = app.listen(3000);
35+
server = app.listen(3001);
3636

3737
server.on("connection", (socket) => {
3838
sockets.add(socket);
@@ -145,7 +145,7 @@ describe("Translator", () => {
145145
const mmm = {
146146
name: "TranslationTest",
147147
file (file) {
148-
return `http://localhost:3000/translations/${file}`;
148+
return `http://localhost:3001/translations/${file}`;
149149
}
150150
};
151151

@@ -186,7 +186,7 @@ describe("Translator", () => {
186186
describe("loadCoreTranslations", () => {
187187
it("should load core translations and fallback", async () => {
188188
const { window, Translator } = createTranslationTestEnvironment();
189-
window.translations = { en: "http://localhost:3000/translations/translation_test.json" };
189+
window.translations = { en: "http://localhost:3001/translations/translation_test.json" };
190190
await Translator.loadCoreTranslations("en");
191191

192192
const en = translationTestData;
@@ -197,7 +197,7 @@ describe("Translator", () => {
197197

198198
it("should load core fallback if language cannot be found", async () => {
199199
const { window, Translator } = createTranslationTestEnvironment();
200-
window.translations = { en: "http://localhost:3000/translations/translation_test.json" };
200+
window.translations = { en: "http://localhost:3001/translations/translation_test.json" };
201201
await Translator.loadCoreTranslations("MISSINGLANG");
202202

203203
const en = translationTestData;
@@ -210,7 +210,7 @@ describe("Translator", () => {
210210
describe("loadCoreTranslationsFallback", () => {
211211
it("should load core translations fallback", async () => {
212212
const { window, Translator } = createTranslationTestEnvironment();
213-
window.translations = { en: "http://localhost:3000/translations/translation_test.json" };
213+
window.translations = { en: "http://localhost:3001/translations/translation_test.json" };
214214
await Translator.loadCoreTranslationsFallback();
215215

216216
const en = translationTestData;

0 commit comments

Comments
 (0)