Skip to content

Commit

Permalink
adjust tests to throwing instead of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Aug 9, 2024
1 parent db2a165 commit 9f461ea
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/language-server/config/__tests__/loadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,11 @@ Object {
it("throws when explorer.search fails", async () => {
writeFilesToDir(dir, { "apollo.config.js": `* 98375^%*&^ its lit` });

const spy = jest.spyOn(console, "error");
// use this to keep the log quiet
spy.mockImplementation();

await loadConfig({
const error = await loadConfig({
configPath: dirPath,
});

expect(spy).toHaveBeenCalledWith(
expect.stringMatching(/config file failed to load/i),
);
}).catch((e: any) => e);

spy.mockRestore();
expect(error.message).toMatch(/config file failed to load/i);
});

it("issues a deprecation warning when loading config from package.json", async () => {
Expand Down Expand Up @@ -234,21 +226,17 @@ Object {
});

it("throws if project type cant be resolved", async () => {
const spy = jest.spyOn(console, "error");
spy.mockImplementation();

writeFilesToDir(dir, {
"apollo.config.js": `module.exports = {}`,
});

await loadConfig({
const error = await loadConfig({
configPath: dirPath,
});
}).catch((e: any) => e);

expect(spy).toHaveBeenCalledWith(
expect.stringMatching(/Config needs to contain a 'client' field./i),
expect(error.message).toMatch(
/Config needs to contain a 'client' field./i,
);
spy.mockRestore();
});
});

Expand Down

0 comments on commit 9f461ea

Please sign in to comment.