Skip to content

Commit

Permalink
Update get-port and consequently convert test setup to an ESM.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlrice committed Oct 6, 2021
1 parent d0cb072 commit 76c1260
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"express": "4.17.1",
"fake-indexeddb": "3.1.3",
"file-loader": "6.2.0",
"get-port": "5.1.1",
"get-port": "6.0.0",
"html-loader": "2.1.2",
"html-webpack-plugin": "5.3.2",
"husky": "7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"testRegex": "[^\\/]+\\.(test|spec)\\.[jt]s$",
"globalSetup": "./setup.js",
"globalSetup": "./setup.mjs",
"globalTeardown": "./teardown.js",
"testEnvironment": "./test-environment.js",
"setupFilesAfterEnv": ["./setup-after-env.js"],
Expand Down
21 changes: 12 additions & 9 deletions src/tests/setup.js → src/tests/setup.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const path = require('path');
const { promisify } = require('util');
import path from 'path';
import { promisify } from 'util';
import { URL } from 'url';

const webpack = require('webpack');
const puppeteer = require('puppeteer');
const express = require('express');
const getPort = require('get-port');
import webpack from 'webpack';
import puppeteer from 'puppeteer';
import express from 'express';
import getPort, { portNumbers } from 'get-port';

const webpackConfig = require('../../webpack.config');
import webpackConfig from '../../webpack.config.js';

const webpackAsync = promisify(webpack);

module.exports = async () => {
const __dirname = new URL('.', import.meta.url).pathname;

export default async () => {
global.__CODE_DIR__ = path.join(__dirname, '.tmp');

// generate code through webpack
Expand All @@ -22,7 +25,7 @@ module.exports = async () => {
const app = express();
app.use(express.static(global.__CODE_DIR__));

const port = await getPort({ port: getPort.makeRange(8000, 8999) });
const port = await getPort({ port: portNumbers(8000, 8999) });
global.__SERVER__ = app.listen(port);

global.__APP_URL__ = `http://localhost:${port}/`;
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5427,10 +5427,10 @@ get-package-type@^0.1.0:
resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==

get-port@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193"
integrity sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==
get-port@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/get-port/-/get-port-6.0.0.tgz#eeac06c17b9d22c2949d4ce5abcc80753afe9be1"
integrity sha512-qSVkVF6Eq1GdL/cBNiFuP4nUHMF7OEMTqEjC6alR2N90u8BFOoO0PFhNTX2QtAUoGrz8NnrSWj85TZ8YXZ6LOA==

get-stdin@^5.0.1:
version "5.0.1"
Expand Down Expand Up @@ -9346,9 +9346,9 @@ react-markdown@7.0.1:
unist-util-visit "^4.0.0"
vfile "^5.0.0"

"react-msa-viewer@git+https://github.com/ebi-webcomponents/react-msa-viewer.git#semver:1.6.3":
"react-msa-viewer@https://github.com/ebi-webcomponents/react-msa-viewer#semver:1.6.3":
version "1.6.3"
resolved "git+https://github.com/ebi-webcomponents/react-msa-viewer.git#827ae186e11539bbaf211dd8168635c48a1dcc78"
resolved "https://github.com/ebi-webcomponents/react-msa-viewer#827ae186e11539bbaf211dd8168635c48a1dcc78"
dependencies:
lodash-es "4.17.15"
plotly-icons "1.3.14"
Expand Down

0 comments on commit 76c1260

Please sign in to comment.