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

Fix tests for node v17 #4314

Merged
merged 3 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all 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 .github/workflows/ci-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
node: ['*', '14', '12']
node: ['17', '*', '14', '12']

runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.os }} node@${{ matrix.node }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@hapi/eslint-plugin": "*",
"@hapi/inert": "^6.0.2",
"@hapi/joi-legacy-test": "npm:@hapi/joi@^15.0.0",
"@hapi/lab": "^24.2.0",
"@hapi/lab": "^24.4.0",
"@hapi/vision": "^6.0.1",
"@hapi/wreck": "^17.0.0",
"handlebars": "^4.7.4",
Expand Down
8 changes: 8 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const ChildProcess = require('child_process');
const Dns = require('dns');

const internals = {};

Expand All @@ -17,3 +18,10 @@ internals.hasLsof = () => {
};

exports.hasLsof = internals.hasLsof();

exports.setDefaultDnsOrder = () => {
// Resolve localhost to ipv4 address on node v17
if (Dns.setDefaultResultOrder) {
Dns.setDefaultResultOrder('ipv4first');
}
};
4 changes: 3 additions & 1 deletion test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ const Common = require('./common');
const internals = {};


const { describe, it } = exports.lab = Lab.script();
const { describe, it, before } = exports.lab = Lab.script();
const expect = Code.expect;


describe('Core', () => {

before(Common.setDefaultDnsOrder);

it('sets app settings defaults', () => {

const server = Hapi.server();
Expand Down
5 changes: 4 additions & 1 deletion test/payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ const Hoek = require('@hapi/hoek');
const Lab = require('@hapi/lab');
const Wreck = require('@hapi/wreck');

const Common = require('./common');

const internals = {};


const { describe, it } = exports.lab = Lab.script();
const { describe, it, before } = exports.lab = Lab.script();
const expect = Code.expect;


describe('Payload', () => {

before(Common.setDefaultDnsOrder);

it('sets payload', async () => {

const payload = '{"x":"1","y":"2","z":"3"}';
Expand Down
5 changes: 4 additions & 1 deletion test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ const Lab = require('@hapi/lab');
const Teamwork = require('@hapi/teamwork');
const Wreck = require('@hapi/wreck');

const Common = require('./common');

const internals = {};


const { describe, it } = exports.lab = Lab.script();
const { describe, it, before } = exports.lab = Lab.script();
const expect = Code.expect;


describe('Request.Generator', () => {

before(Common.setDefaultDnsOrder);

it('decorates request multiple times', async () => {

const server = Hapi.server();
Expand Down
5 changes: 4 additions & 1 deletion test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ const Lab = require('@hapi/lab');
const Vision = require('@hapi/vision');
const Wreck = require('@hapi/wreck');

const Common = require('./common');
const Pkg = require('../package.json');


const internals = {};


const { describe, it } = exports.lab = Lab.script();
const { describe, it, before } = exports.lab = Lab.script();
const expect = Code.expect;


describe('Server', () => {

before(Common.setDefaultDnsOrder);

describe('auth', () => {

it('adds auth strategy via plugin', async () => {
Expand Down
4 changes: 3 additions & 1 deletion test/transmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const Common = require('./common');
const internals = {};


const { describe, it } = exports.lab = Lab.script();
const { describe, it, before } = exports.lab = Lab.script();
const expect = Code.expect;


describe('transmission', () => {

before(Common.setDefaultDnsOrder);

describe('send()', () => {

it('handlers invalid headers in error', async () => {
Expand Down