Browse Source

random port and better timing for tests

Jairo 6 years ago
parent
commit
9713fde691
1 changed files with 7 additions and 6 deletions
  1. 7 6
      test/basic_test.js

+ 7 - 6
test/basic_test.js

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