Skip to content

Commit 412fc0f

Browse files
committed
Fixed tests in CI envs
1 parent c30e38d commit 412fc0f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/index.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function check(opts = {}) {
5151

5252
// bail immediately if update notifications have been explicitly disabled or we're running
5353
// within a test
54-
if (!force && (process.env.NO_UPDATE_NOTIFIER || process.env.NODE_ENV === 'test' || isCI)) {
54+
if (!force && !process.env.FORCE_UPDATE_NOTIFIER && (process.env.NO_UPDATE_NOTIFIER || process.env.NODE_ENV === 'test' || isCI)) {
5555
return {};
5656
}
5757

@@ -243,7 +243,9 @@ async function getLatestVersion(name, distTag, opts) {
243243
},
244244
responseType: 'json',
245245
retry: 0,
246-
timeout: Object.prototype.hasOwnProperty.call(opts, 'timeout') ? opts.timeout : 1000,
246+
timeout: {
247+
request: Object.prototype.hasOwnProperty.call(opts, 'timeout') ? opts.timeout : 1000
248+
},
247249
url: new URL(encodeURIComponent(name).replace(/^%40/, '@'), regUrl)
248250
};
249251
let info;

‎test/test-check-kit.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const { highlight } = snooplogg.styles;
1818
process.env.TEST_META_DIR = tmp.dirSync({ prefix: 'check-kit-test' }).name;
1919

2020
describe('check-kit', function () {
21+
beforeEach(() => {
22+
process.env.FORCE_UPDATE_NOTIFIER = 1;
23+
});
24+
2125
afterEach(async () => {
2226
await fs.remove(process.env.TEST_META_DIR);
2327
});
@@ -76,6 +80,7 @@ describe('check-kit', function () {
7680
describe('Environment check skip', () => {
7781
it('should skip check if NO_UPDATE_NOTIFIER is set', async () => {
7882
try {
83+
delete process.env.FORCE_UPDATE_NOTIFIER;
7984
process.env.NO_UPDATE_NOTIFIER = 1;
8085
expect(await check()).to.deep.equal({});
8186
} finally {
@@ -85,6 +90,7 @@ describe('check-kit', function () {
8590

8691
it('should skip check if NODE_ENV is set to test', async () => {
8792
try {
93+
delete process.env.FORCE_UPDATE_NOTIFIER;
8894
process.env.NODE_ENV = 'test';
8995
expect(await check()).to.deep.equal({});
9096
} finally {

0 commit comments

Comments
 (0)