Skip to content

Commit d478559

Browse files
authored
test: fix a incorrect the usage of the assert function (#2109)
improve to clear require cache.
1 parent d32e4cd commit d478559

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/afraid-swans-rescue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
import { afterEach, describe, test } from 'node:test';
22
import assert from 'node:assert';
3-
import { getUrl } from './get_usage_data_url';
3+
import url from 'node:url';
44

55
void describe('getUrl', () => {
66
afterEach(() => {
77
delete process.env.AMPLIFY_BACKEND_USAGE_TRACKING_ENDPOINT;
8+
delete require.cache[require.resolve('./get_usage_data_url')];
89
});
910
void test('that prod URL is returned when the env for beta URL is not set', () => {
10-
assert(getUrl(), 'https://api.cli.amplify.aws/v1.0/metrics');
11+
// eslint-disable-next-line @typescript-eslint/no-var-requires
12+
const { getUrl } = require('./get_usage_data_url');
13+
assert.equal(
14+
url.format(getUrl()),
15+
'https://api.cli.amplify.aws/v1.0/metrics'
16+
);
1117
});
1218

1319
void test('that BETA URL is returned when the env for beta URL is set', () => {
1420
process.env.AMPLIFY_BACKEND_USAGE_TRACKING_ENDPOINT =
1521
'https://aws.amazon.com/amplify/';
16-
assert(getUrl(), 'https://aws.amazon.com/amplify/');
22+
// eslint-disable-next-line @typescript-eslint/no-var-requires
23+
const { getUrl } = require('./get_usage_data_url');
24+
assert.equal(url.format(getUrl()), 'https://aws.amazon.com/amplify/');
1725
});
1826
});

0 commit comments

Comments
 (0)