mirror of
https://github.com/fluencelabs/js-libp2p-websockets
synced 2025-03-17 09:00:53 +00:00
Clean up browser + nodejs tests
This commit is contained in:
parent
ce62196bd9
commit
138c82e2ca
@ -4,11 +4,12 @@ module.exports = function (config) {
|
|||||||
frameworks: ['mocha'],
|
frameworks: ['mocha'],
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
'tests/browser.js'
|
'tests/browser-nodejs/browser.js'
|
||||||
],
|
],
|
||||||
|
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'tests/*': ['webpack']
|
'tests/*': ['webpack'],
|
||||||
|
'tests/browser-nodejs/*': ['webpack']
|
||||||
},
|
},
|
||||||
|
|
||||||
webpack: {
|
webpack: {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"test:compliance:transport": "node tests/transport.js",
|
"test:compliance:transport": "node tests/transport.js",
|
||||||
"test:specific": "mocha tests/*-test.js",
|
"test:specific": "mocha tests/*-test.js",
|
||||||
"test:node": "npm run test:specific",
|
"test:node": "npm run test:specific",
|
||||||
"test:browser": "node tests/karma",
|
"test:browser": "node tests/browser-nodejs/test.js",
|
||||||
"test": "npm run test:node && npm run test:browser",
|
"test": "npm run test:node && npm run test:browser",
|
||||||
"test-2": "npm run test:specific && npm run test:compliance:transport && npm run test:compliance:connection",
|
"test-2": "npm run test:specific && npm run test:compliance:transport && npm run test:compliance:connection",
|
||||||
"lint": "standard"
|
"lint": "standard"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const expect = require('chai').expect
|
||||||
const WSlibp2p = require('../src')
|
const WSlibp2p = require('../../src')
|
||||||
const multiaddr = require('multiaddr')
|
const multiaddr = require('multiaddr')
|
||||||
|
|
||||||
describe('libp2p-websockets', function () {
|
describe('libp2p-websockets', function () {
|
@ -1,12 +1,12 @@
|
|||||||
const Server = require('karma').Server
|
const Server = require('karma').Server
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const WSlibp2p = require('../src')
|
const WSlibp2p = require('../../src')
|
||||||
const multiaddr = require('multiaddr')
|
const multiaddr = require('multiaddr')
|
||||||
|
|
||||||
var ws
|
var ws
|
||||||
|
|
||||||
function createServer (done) {
|
function createListener (done) {
|
||||||
ws = new WSlibp2p()
|
ws = new WSlibp2p()
|
||||||
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/websockets')
|
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/websockets')
|
||||||
ws.createListener(mh, (socket) => {
|
ws.createListener(mh, (socket) => {
|
||||||
@ -18,11 +18,11 @@ function stopServer (done) {
|
|||||||
ws.close(done)
|
ws.close(done)
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTests (done) {
|
function run (done) {
|
||||||
new Server({
|
new Server({
|
||||||
configFile: path.join(__dirname, '/../karma.conf.js'),
|
configFile: path.join(__dirname, '/../../karma.conf.js'),
|
||||||
singleRun: true
|
singleRun: true
|
||||||
}, done).start()
|
}, done).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
createServer(() => runTests(() => stopServer(() => null)))
|
createListener(() => run((exitCode) => stopServer(() => process.exit(exitCode))))
|
Loading…
x
Reference in New Issue
Block a user