Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions src/commands/crashlytics-sourcemap-upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
execSyncStub.withArgs("git rev-parse HEAD").returns(Buffer.from("a".repeat(40)));
clientPostStub = sandbox.stub(Client.prototype, "post").resolves({
status: 200,
response: {} as any,

Check warning on line 56 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 56 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
body: {},
});
});
Expand Down Expand Up @@ -94,7 +94,7 @@
});

it("should throw an error if the mapping file path is invalid", async () => {
expect(

Check warning on line 97 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
command.runner()("invalid/path", {
app: "test-app",
}),
Expand Down Expand Up @@ -128,23 +128,29 @@
});

it("should find and upload mapping files in the current directory if no path is provided", async () => {
await command.runner()(undefined, { app: "test-app" });
const uploadedFiles = gcsMock.uploadObject
.getCalls()
.map((call) => call.args[0].file)
.sort();
expect(uploadedFiles[0]).to.match(
/test-app-.*-src-test-fixtures-mapping-files-mock_mapping\.js\.map\.zip/,
);
expect(uploadedFiles[1]).to.match(
/test-app-.*-src-test-fixtures-mapping-files-subdir-subdir_mock_mapping\.js\.map\.zip/,
);
expect(uploadedFiles[2]).to.match(
/test-app-.*-src-test-fixtures-mapping-files-with-js-main\.js\.map\.zip/,
);
expect(uploadedFiles[3]).to.match(
/test-app-.*-src-test-fixtures-mapping-files-with-js-other\.js\.map\.zip/,
);
const originalCwd = process.cwd();
try {
process.chdir("src/test");
await command.runner()(undefined, { app: "test-app" });
const uploadedFiles = gcsMock.uploadObject
.getCalls()
.map((call) => call.args[0].file)
.sort();
expect(uploadedFiles[0]).to.match(
/test-app-.*-fixtures-mapping-files-mock_mapping\.js\.map\.zip/,
);
expect(uploadedFiles[1]).to.match(
/test-app-.*-fixtures-mapping-files-subdir-subdir_mock_mapping\.js\.map\.zip/,
);
expect(uploadedFiles[2]).to.match(
/test-app-.*-fixtures-mapping-files-with-js-main\.js\.map\.zip/,
);
expect(uploadedFiles[3]).to.match(
/test-app-.*-fixtures-mapping-files-with-js-other\.js\.map\.zip/,
);
} finally {
process.chdir(originalCwd);
}
});

it("should find obfuscated mapping files linked by sourceMappingURL in a directory", async () => {
Expand All @@ -168,7 +174,7 @@
expect(clientPostStub).to.be.calledTwice;
const apiPayloads = clientPostStub
.getCalls()
.map((call) => call.args[1].sourceMap.obfuscatedFilePath)

Check warning on line 177 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe return of an `any` typed value

Check warning on line 177 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .sourceMap on an `any` value
.sort();

expect(apiPayloads[0]).to.equal("src/test/fixtures/mapping-files-with-js/main.js.map");
Expand Down Expand Up @@ -229,13 +235,13 @@
expect(args[0]).to.match(
/projects\/test-project\/apps\/test-app\/locations\/global\/sourceMaps/,
);
expect(args[1].sourceMap).to.deep.equal({

Check warning on line 238 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .sourceMap on an `any` value
name: "projects/test-project/apps/test-app/locations/global/sourceMaps/759213742",
version: "a".repeat(40),
obfuscatedFilePath: "src/test/fixtures/mapping-files/mock_mapping.js.map",
fileUri: `gs://${BUCKET_NAME}/test-object`,
});
expect(args[2].queryParams).to.deep.equal({ allowMissing: "true" });

Check warning on line 244 in src/commands/crashlytics-sourcemap-upload.spec.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .queryParams on an `any` value
});

it("should warn if registration fails", async () => {
Expand Down
Loading