Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
# Node setup
language: node_js
node_js:
- '14'
- '18'

# Chrome addon
addons:
Expand Down
3 changes: 2 additions & 1 deletion babel.config.js → babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ module.exports = function (api) {
'@babel/preset-env',
{
debug: false,
modules: false,
targets: {
node: '12',
node: '18',
},
},
],
Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const DockerLauncher = require('./lib/launcher');
import DockerLauncher from './lib/launcher';

module.exports.default = DockerLauncher;
module.exports.launcher = DockerLauncher;
const _default = DockerLauncher;
export { _default as default };
export const launcher = DockerLauncher;
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"checkJs": false,
"module": "node16",
},
"include": ["./**/*.js"],
"exclude": ["node_modules", "lib"]
}
11,768 changes: 6,454 additions & 5,314 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wdio-docker-service",
"version": "3.3.1",
"version": "4.0.0",
"description": "WebdriverIO service to start and stop docker container (for Selenium and more)",
"repository": {
"type": "git",
Expand All @@ -10,6 +10,7 @@
"url": "https://github.com/stsvilik/wdio-docker-service/issues"
},
"main": "index.js",
"type": "module",
"scripts": {
"prepublishOnly": "rm -rf ./lib && npm run build",
"build": "babel ./src --out-dir ./lib",
Expand All @@ -30,30 +31,32 @@
"author": "Simon Tsvilik",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/register": "^7.21.0",
"@wdio/cli": "^7.30.2",
"@wdio/local-runner": "^7.30.2",
"@wdio/mocha-framework": "^7.30.2",
"@wdio/selenium-standalone-service": "^7.30.2",
"@wdio/spec-reporter": "^7.30.2",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/register": "^7.22.15",
"@types/chai": "^4.3.9",
"@types/fs-extra": "^11.0.3",
"@types/mocha": "^10.0.3",
"@types/node-fetch": "^2.6.7",
"@types/sinon": "^10.0.20",
"@wdio/cli": "^8.20.5",
"@wdio/local-runner": "^8.20.5",
"@wdio/mocha-framework": "^8.20.3",
"@wdio/spec-reporter": "^8.20.0",
"chai": "^4.3.7",
"chromedriver": "^112.0.0",
"coveralls": "^3.1.1",
"eslint": "^8.38.0",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"sinon": "^15.0.3",
"wdio-chromedriver-service": "^8.1.1",
"webdriverio": "^7.30.2"
"webdriverio": "^8.20.4"
},
"dependencies": {
"@wdio/logger": "^7.26.0",
"@wdio/logger": "^8.16.17",
"fs-extra": "^11.1.1",
"node-fetch": "^2.6.9"
"node-fetch": "^3.3.2"
},
"contributors": [
"Simon Tsvilik <[email protected]>"
Expand Down
7 changes: 4 additions & 3 deletions src/launcher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs-extra';
import Docker from './utils/docker';
import getFilePath from './utils/getFilePath';
import logger from '@wdio/logger';
import Docker from './utils/docker.js';
import getFilePath from './utils/getFilePath.js';

const DEFAULT_LOG_FILENAME = 'docker-log.txt';
const Logger = logger('wdio-docker-service');
Expand Down Expand Up @@ -91,4 +91,5 @@ class DockerLauncher {
}
}

module.exports = DockerLauncher;
export { DockerLauncher };
export default DockerLauncher;
6 changes: 3 additions & 3 deletions src/modules/dockerEvents.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exec } from 'child_process';
import serializeOptions from '../utils/optionsSerializer';
import deepMerge from '../utils/deepMerge';
import serializeOptions from '../utils/optionsSerializer.js';
import deepMerge from '../utils/deepMerge.js';

const NANOSECONDS = 1000000;
const DEFAULT_OPTIONS = {
Expand Down Expand Up @@ -128,5 +128,5 @@ process.on('message', (options) => {
DockerEvents.init(options);
});

module.exports = DockerEvents;
export default DockerEvents;

13 changes: 7 additions & 6 deletions src/utils/docker.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import deepMerge from './deepMerge';
import { EventEmitter } from 'events';
import fs from 'fs-extra';
import path from 'path';
import Ping from './ping';
import { runCommand, runProcess } from './childProcess';
import { EventEmitter } from 'events';
import serializeOptions from './optionsSerializer';
import DockerEventsListener from './dockerEventsListener';

import Ping from './ping.js';
import deepMerge from './deepMerge.js';
import serializeOptions from './optionsSerializer.js';
import { runCommand, runProcess } from './childProcess.js';
import DockerEventsListener from './dockerEventsListener.js';

const SPACE = ' ';
const INSPECT_DOCKER_INTERVAL = 500;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/dockerEventsListener.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import EventEmitter from 'events';
import { fork } from 'child_process';
import path from 'path';
import * as url from 'url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

const DOCKER_EVENTS_MODULE = path.resolve(__dirname, '..', 'modules/dockerEvents');

Expand Down
2 changes: 1 addition & 1 deletion src/utils/optionsSerializer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import camelToDash from './camelToDash';
import camelToDash from './camelToDash.js';

const RX_SPACES = /(\s)/g;
const RX_IS_ESCAPED = /^(["'])([^"']+)(["'])$/;
Expand Down
10 changes: 5 additions & 5 deletions test/integration/docker-app/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { expect } = require('chai');
const fs = require('fs');
const path = require('path');
import { expect } from 'chai';
import { statSync } from 'fs';
import { join } from 'path';

describe('when using Docker to run application', function() {
it('should run a test', async function() {
Expand All @@ -10,8 +10,8 @@ describe('when using Docker to run application', function() {
});

it('should have created a log file', function() {
const filePath = path.join(process.cwd(), 'docker-log.txt');
const file = fs.statSync(filePath);
const filePath = join(process.cwd(), 'docker-log.txt');
const file = statSync(filePath);
expect(file.size).to.be.above(0);
});
});
23 changes: 13 additions & 10 deletions test/integration/docker-app/wdio.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const path = require('path');
const DockerLauncher = require('../../../lib/launcher');
import { join } from 'path';
import DockerLauncher from '../../../lib/launcher.js';
import * as url from 'url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

exports.config = {
host: 'localhost',
export const config = {
host: '127.0.0.1',
specs: [
'./test/integration/docker-app/*.spec.js'
],
Expand All @@ -15,7 +17,7 @@ exports.config = {
}
}],

baseUrl: 'http://localhost:8080',
baseUrl: 'http://127.0.0.1:8080',
logLevel: 'debug',

waitforTimeout: 10000,
Expand All @@ -27,19 +29,20 @@ exports.config = {
ui: 'bdd'
},
reporters: ['spec'],
browserName: 'chrome',
browserVersion: '118.0-chromedriver-118.0',
services: [
'chromedriver',
[new DockerLauncher()]
[DockerLauncher]
],
dockerLogs: './',
dockerOptions: {
image: 'nginx',
healthCheck: 'http://localhost:8080',
healthCheck: 'http://127.0.0.1:8080',
options: {
p: ['8080:8080'],
v: [
`${ path.join(__dirname, '/app/') }:/usr/share/nginx/html:ro`,
`${ path.join(__dirname, '/nginx.conf') }:/etc/nginx/nginx.conf:ro`
`${ join(__dirname, '/app/') }:/usr/share/nginx/html:ro`,
`${ join(__dirname, '/nginx.conf') }:/etc/nginx/nginx.conf:ro`
],
healthCmd: '"curl -sS http://127.0.0.1:8080 || exit 1"',
healthTimeout: '10s',
Expand Down
10 changes: 5 additions & 5 deletions test/integration/docker-selenium/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { expect } = require('chai');
const fs = require('fs');
const path = require('path');
import { expect } from 'chai';
import { statSync } from 'fs';
import { join } from 'path';

describe('when using Docker to run Selenium', function() {
it('should run a test', async function() {
Expand All @@ -10,8 +10,8 @@ describe('when using Docker to run Selenium', function() {
});

it('should have created a log file', function() {
const filePath = path.join(process.cwd(), 'docker-log.txt');
const file = fs.statSync(filePath);
const filePath = join(process.cwd(), 'docker-log.txt');
const file = statSync(filePath);
expect(file.size).to.be.above(0);
});
});
6 changes: 3 additions & 3 deletions test/integration/docker-selenium/wdio.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const DockerLauncher = require('../../../lib/launcher');
import DockerLauncher from '../../../lib/launcher.js';

exports.config = {
export const config = {
host: 'localhost',
specs: [
'./test/integration/docker-selenium/*.spec.js'
Expand All @@ -24,7 +24,7 @@ exports.config = {
},
reporters: ['spec'],
services: [
[new DockerLauncher()]
[[DockerLauncher]]
],
dockerLogs: './',
dockerOptions: {
Expand Down
2 changes: 1 addition & 1 deletion test/testDockerEvents.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const DockerEventsListener = require('../lib/utils/dockerEventsListener').default;
import DockerEventsListener from '../lib/utils/dockerEventsListener';
const del = new DockerEventsListener();

del.on('container.create', (event) => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/launcherSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { stub, spy } from 'sinon';
import Docker from '../../src/utils/docker';

describe('DockerLauncher', function() {
const DockerLauncher = require('../../src/launcher');
const DockerLauncher = require('../../src/launcher.js');
let launcher;

beforeEach(function() {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/modules/dockerEventsSpec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { stub, spy } from 'sinon';
import ChildProcess from 'child_process';
import * as ChildProcess from 'child_process';
import MockChildProcess from '../../mocks/MockChildProcess';
import MockRawDockerEvent from '../../mocks/MockRawDockerEvent';
import MockRawDockerEvent from '../../mocks/MockRawDockerEvent.json';
import DockerEvents from '../../../src/modules/dockerEvents';

describe('DockerEvents module', function () {
Expand Down