Skip to content

Commit d3f1c3f

Browse files
authored
Explicitly avoid making network calls in test (#235)
1 parent a1ae388 commit d3f1c3f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/importer/src/usage.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ exports.UsageCollection = class {
2727
}
2828

2929
updateDUDKPermission(dudkPermission) {
30+
if (process.env.NODE_ENV == "test") {
31+
return
32+
}
33+
34+
3035
const projectDir = path.resolve(projectDirectory() || process.cwd());
3136
const usage_config = path.join(projectDir, "usage-data-config.json")
3237

@@ -56,6 +61,9 @@ exports.UsageCollection = class {
5661
recordEvent(eventName) {
5762
if (!this.enabled) return false;
5863

64+
// If we are testing, then pretend this worked without making the request
65+
if (process.env.NODE_ENV == "test") return true;
66+
5967
// Make the request in a block that will allow us to return
6068
// immediately whilst the event is recorded
6169
(async () => {

0 commit comments

Comments
 (0)