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

added test cleanup clause to server tests

Brandon Wong 7 роки тому
батько
коміт
a1ed00f6fd

+ 8 - 5
dnodemongo/test/service.js

@@ -6,10 +6,10 @@ import http from 'http';
 
 const tapetest = _test(tape);
 
-tapetest('service', async function testService(t) {
-    const server = fork('build/service.js'),
-        connstring = 'http://localhost:8080';
+const server = fork('build/service.js'),
+    connstring = 'http://localhost:8728';
 
+tapetest('service', async function testService(assert) {
     try {
         await waitPro();
         const data = await requestPro(connstring + '/');
@@ -17,11 +17,14 @@ tapetest('service', async function testService(t) {
     }
     catch(e) {
         console.log('error somewhere', e);
-        t.fail('error somewhere');
+        assert.fail('error somewhere');
     }
 
+    assert.end();
+});
+
+tapetest.onFinish(async function cleanup() {
     server.kill();
-    t.end();
 });
 
 

+ 8 - 5
elmserver/server/test/service.js

@@ -6,10 +6,10 @@ import http from 'http';
 
 const tapetest = _test(tape);
 
-tapetest('service', async function testService(t) {
-    const server = fork('build/service.js'),
-        connstring = 'http://localhost:8080';
+const server = fork('build/service.js'),
+    connstring = 'http://localhost:8728';
 
+tapetest('service', async function testService(assert) {
     try {
         await waitPro();
         const data = await requestPro(connstring + '/');
@@ -17,11 +17,14 @@ tapetest('service', async function testService(t) {
     }
     catch(e) {
         console.log('error somewhere', e);
-        t.fail('error somewhere');
+        assert.fail('error somewhere');
     }
 
+    assert.end();
+});
+
+tapetest.onFinish(async function cleanup() {
     server.kill();
-    t.end();
 });
 
 

+ 8 - 5
service/test/service.js

@@ -6,10 +6,10 @@ import http from 'http';
 
 const tapetest = _test(tape);
 
-tapetest('service', async function testService(t) {
-    const server = fork('build/service.js'),
-        connstring = 'http://localhost:8728';
+const server = fork('build/service.js'),
+    connstring = 'http://localhost:8728';
 
+tapetest('service', async function testService(assert) {
     try {
         await waitPro();
         const data = await requestPro(connstring + '/');
@@ -17,11 +17,14 @@ tapetest('service', async function testService(t) {
     }
     catch(e) {
         console.log('error somewhere', e);
-        t.fail('error somewhere');
+        assert.fail('error somewhere');
     }
 
+    assert.end();
+});
+
+tapetest.onFinish(async function cleanup() {
     server.kill();
-    t.end();
 });
 
 

+ 7 - 4
socket/test/server.js

@@ -11,20 +11,23 @@ const serverhost = 'localhost',
     serverport = 2424,
     server = child_process.fork('build/server.js');
 
-tapetest('test server', async function testServer(t) {
+tapetest('test server', async function testServer(assert) {
     let client;
 
     try {
         await waitPro();
         const data = await requestPro(`http://${serverhost}:${serverport}`);
-        t.equal(data, 'working', 'received message from server');
+        assert.equal(data, 'working', 'received message from server');
     }
     catch(e) {
         console.log('error somewhere', e);
-        t.fail('error somewhere');
+        assert.fail('error somewhere');
     }
 
-    t.end();
+    assert.end();
+});
+
+tapetest.onFinish(async function cleanup() {
     server.kill();
 });