Skip to content

Commit fd4c2ca

Browse files
fix: logging in client
1 parent 581cd98 commit fd4c2ca

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

client-src/clients/SockJSClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const SockJS = require('../modules/sockjs-client');
4-
const { log } = require('../modules/logger');
4+
const { log } = require('../utils/log');
55
const BaseClient = require('./BaseClient');
66

77
module.exports = class SockJSClient extends BaseClient {

client-src/clients/WebsocketClient.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
'use strict';
22

3-
const { log } = require('../modules/logger');
3+
const { log } = require('../utils/log');
44
const BaseClient = require('./BaseClient');
55

66
module.exports = class WebsocketClient extends BaseClient {
77
constructor(url) {
88
super();
9+
910
const wsUrl = url.replace(/^(?:http|chrome-extension|file)/i, 'ws');
10-
this.client = new WebSocket(wsUrl);
1111

12+
this.client = new WebSocket(wsUrl);
1213
this.client.onerror = (err) => {
1314
log.error(err);
1415
};

test/client/clients/SockJSClient.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const express = require('express');
55
const sockjs = require('sockjs');
66
const port = require('../../ports-map').sockJSClient;
77

8-
jest.setMock('../../../client-src/modules/logger', {
8+
jest.setMock('../../../client-src/utils/log', {
99
log: {
1010
error: jest.fn(),
1111
},
1212
});
1313

1414
describe('SockJSClient', () => {
1515
const SockJSClient = require('../../../client-src/clients/SockJSClient');
16-
const { log } = require('../../../client-src/modules/logger');
16+
const { log } = require('../../../client-src/utils/log');
1717
let consoleMock;
1818
let socketServer;
1919
let server;

test/client/clients/WebsocketClient.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const express = require('express');
55
const ws = require('ws');
66
const port = require('../../ports-map').WebsocketClient;
77

8-
jest.setMock('../../../client-src/modules/logger', {
8+
jest.setMock('../../../client-src/utils/log', {
99
log: {
1010
error: jest.fn(),
1111
},
1212
});
1313

1414
describe('WebsocketClient', () => {
1515
const WebsocketClient = require('../../../client-src/clients/WebsocketClient');
16-
const { log } = require('../../../client-src/modules/logger');
16+
const { log } = require('../../../client-src/utils/log');
1717

1818
let socketServer;
1919
let server;

test/e2e/ClientOptions.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,24 +394,30 @@ describe('Client console.log', () => {
394394
];
395395

396396
transportModes.forEach(async (mode) => {
397-
await cases.forEach(async ({ title, options }) => {
397+
cases.forEach(async ({ title, options }) => {
398398
title += ` (${
399399
Object.keys(mode).length ? mode.transportMode : 'default'
400400
})`;
401+
401402
options = { ...mode, ...options };
403+
402404
const testOptions = Object.assign({}, baseOptions, options);
403-
await it(title, (done) => {
405+
406+
it(title, (done) => {
404407
testServer.startAwaitingCompilation(config, testOptions, async () => {
405408
const res = [];
406409
const { page, browser } = await runBrowser();
410+
407411
page.goto(`http://localhost:${port2}/main`);
408412
page.on('console', ({ _text }) => {
409413
res.push(_text);
410414
});
415+
411416
// wait for load before closing the browser
412417
await page.waitForNavigation({ waitUntil: 'load' });
413418
await page.waitForTimeout(beforeBrowserCloseDelay);
414419
await browser.close();
420+
415421
// Order doesn't matter, maybe we should improve that in future
416422
await expect(res.sort()).toMatchSnapshot();
417423
await testServer.close(done);

0 commit comments

Comments
 (0)