Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds get-port to ensure we have an available port #322

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions node-tests/setup-middleware-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fetch = require('node-fetch');
const fs = require('fs');
const tmp = require('tmp');
const express = require('express');
const getPort = require('get-port');
const readJSONSync = require('fs-extra').readJSONSync;
const {
setupMiddleware,
Expand All @@ -29,8 +30,9 @@ QUnit.module('setupMiddleware', function (hooks) {
let tmpDir;
let app;
let server;
let port;

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
tmpDir = createTmpDir();
app = express();

Expand All @@ -41,7 +43,8 @@ QUnit.module('setupMiddleware', function (hooks) {
reportDir: 'ember-a11y-report',
});

server = app.listen(3000);
port = await getPort({ port: 3000 });
server = app.listen(port);
});

hooks.afterEach(function () {
Expand All @@ -53,7 +56,7 @@ QUnit.module('setupMiddleware', function (hooks) {
async function (assert) {
let data = [buildResult(violationsFixture)];

let json = await fetch('http://localhost:3000/report-violations', {
let json = await fetch(`http://localhost:${port}/report-violations`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"express": "^4.17.1",
"get-port": "5",
"loader.js": "^4.7.0",
"node-fetch": "^2.6.0",
"npm-run-all": "^4.1.5",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7118,6 +7118,11 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1:
has "^1.0.3"
has-symbols "^1.0.1"

get-port@5:
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-stdin@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe"
Expand Down