Переглянути джерело

random port and better timing for tests

Jairo 6 роки тому
батько
коміт
9713fde691
1 змінених файлів з 7 додано та 6 видалено
  1. 7 6
      test/basic_test.js

+ 7 - 6
test/basic_test.js

@@ -1,25 +1,26 @@
 /// <reference path="./steps.d.ts" />
 const express = require("express");
+const port = Math.floor(Math.random() * (8000 - 2000 + 1)) + 2000;
 
 BeforeSuite((I) => {
     const app = express()
     app.use(express.static('public'))
-    app.listen(3456)
+    app.listen(port)
 });
 
 Feature('Connection');
 
 Scenario('Data Channel ping pong', async (I) => {
-    I.amOnPage("http://localhost:3456")
-    I.wait(2)
+    I.amOnPage("http://localhost:" + port)
+    I.wait(1)
     I.openNewTab();
-    I.amOnPage("http://localhost:3456")
-    I.wait(2)
+    I.amOnPage("http://localhost:" + port)
+    I.wait(1)
     const id2 = await I.grabTextFrom("#id")
     I.switchToPreviousTab(1)
     I.wait(1)
     I.executeScript(`connect("${id2}")`)
-    I.wait(2)
+    I.wait(1)
     I.see("pong")
 });