Skip to content

Commit

Permalink
chore(ci): make tests pass on Node.js versions that support ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmukuthu committed Sep 17, 2023
1 parent b4770c1 commit 78249a1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/unexpected-knex.spec.js
Expand Up @@ -8,10 +8,14 @@ const unexpectedKnex = require('../lib/unexpected-knex');
const dontIndent = require('dedent-js');
const assertErrorOuput = process.env.ASSERT_ERROR_OUTPUT !== 'false';

// This file is `require`d here so that it's cached by Node.js before we go
// ahead and mock out `require`, since knex's migrator require's it while doing
// its job.
// This file is `require`d lazily by Knex's migrator, so we have to require it
// here so that it's cached by Node.js before we go on to mock out `require`.
require('knex/lib/util/import-file.js');
// Knex `require`s migrations lazily and in the process tries to figure out if
// it should use `import` or `require`. The following hacks make it bypass those
// checks and default to using `require`.
if (process.env.npm_package_json) delete process.env.npm_package_json;
if (process.env.npm_package_type) delete process.env.npm_package_type;

describe('unexpected-knex', function () {
const host = process.env.PGHOST || 'localhost';
Expand Down

0 comments on commit 78249a1

Please sign in to comment.