Skip to content

Commit

Permalink
Merge pull request #353 from auto-mat/could-not-find-coverage-file
Browse files Browse the repository at this point in the history
Could not find coverage file
  • Loading branch information
ryanluker committed Jan 10, 2022
2 parents 1fa499c + 4e31325 commit 345233a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/files/filesloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class FilesLoader {
const fileNames = this.configStore.coverageFileNames;
const files = await this.findCoverageInWorkspace(fileNames);
if (!files.size) {
window.showWarningMessage("Could not find a Coverage file!");
window.showWarningMessage("Could not find a Coverage file! Searched for " + fileNames.join(", "));
return new Set();
}
return files;
Expand Down Expand Up @@ -92,9 +92,16 @@ export class FilesLoader {
dot: true,
ignore: this.configStore.ignoredPathGlobs,
realpath: true,
strict: false,
},
(err, files) => {
if (!files || !files.length) { return resolve(new Set()); }
if (!files || !files.length) {
// Show any errors if no file was found.
if (err) {
window.showWarningMessage(`An error occured while looking for the coverage file ${err}`);
}
return resolve(new Set());
}
const setFiles = new Set<string>();
files.forEach((file) => setFiles.add(file));
return resolve(setFiles);
Expand Down
3 changes: 2 additions & 1 deletion test/files/filesloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ suite("FilesLoader Tests", () => {

test("findCoverageFiles returns an error if no coverage file @unit", async () => {
stubConfig.manualCoverageFilePaths = [];
stubConfig.coverageFileNames = ["lcov.info"];
const filesLoader = new FilesLoader(stubConfig);
sinon.stub(filesLoader as any, "findCoverageInWorkspace").resolves(new Map());

const stubShowWarningMessage = sinon.spy(vscode.window, "showWarningMessage");

await filesLoader.findCoverageFiles();
expect(stubShowWarningMessage).to.be.calledWith("Could not find a Coverage file!");
expect(stubShowWarningMessage).to.be.calledWith("Could not find a Coverage file! Searched for lcov.info");
});

test("findCoverageFiles returns manual coverage paths if set @unit", async () => {
Expand Down

0 comments on commit 345233a

Please sign in to comment.