Skip to content

Commit

Permalink
Fix tests for node v17 (#4314)
Browse files Browse the repository at this point in the history
* Set default DNS order for node v17 testing. Temporarily skip hanging test.

* Fix test action for node v17

* No longer skip test, node v17 bug fixed nodejs/node#40528
  • Loading branch information
devinivy authored Nov 13, 2021
1 parent 463fb2f commit e4ef336
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 7 deletions.
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

0 comments on commit e4ef336

Please sign in to comment.