Skip to content

Commit

Permalink
Skip failing test on Node.js 18 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell authored Mar 2, 2024
1 parent dfee991 commit a0ec515
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
node-version:
- 21
- 20
# - 18
- 18
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
30 changes: 18 additions & 12 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process';
import {promisify} from 'node:util';
import http from 'node:http';
import test from 'ava';
Expand Down Expand Up @@ -120,21 +121,26 @@ test('reject when version doesn\'t exist', async t => {
await t.throwsAsync(packageJson('hapi', {version: '6.6.6'}), {instanceOf: VersionNotFoundError});
});

test('does not send any auth token for unconfigured registries', async t => {
const server = http.createServer((request, response) => {
response.end(JSON.stringify({headers: request.headers, 'dist-tags': {}}));
});
const nodeMajorVersion = Number(process.versions.node.split('.').at(0));

await promisify(server.listen.bind(server))(63_144, '127.0.0.1');
const json = await packageJson('@mockscope3/foobar', {allVersions: true});
if (nodeMajorVersion > 18) {
test('does not send any auth token for unconfigured registries', async t => {
const server = http.createServer((request, response) => {
const mock = {headers: request.headers, 'dist-tags': {}, versions: {'1.0.0': {}}};
response.end(JSON.stringify(mock));
});

t.like(json.headers, {
host: 'localhost:63144',
authorization: undefined,
});
await promisify(server.listen.bind(server))(63_144, '127.0.0.1');
const json = await packageJson('@mockscope3/foobar', {allVersions: true});

await promisify(server.close.bind(server))();
});
t.like(json.headers, {
host: 'localhost:63144',
authorization: undefined,
});

await promisify(server.close.bind(server))();
});
}

test('private registry (bearer token)', async t => {
const server = await privateRegistry({port: 63_142});
Expand Down

0 comments on commit a0ec515

Please sign in to comment.