Skip to content

Commit

Permalink
only normalizeOutput in snapshot tests if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
RamIdeas committed Mar 13, 2024
1 parent 887f47a commit e6d37d5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { normalizeOutput } from "../../../e2e/helpers/normalize";
import { mockAccountId, mockApiToken } from "../helpers/mock-account-id";
import { mockConsoleMethods } from "../helpers/mock-console";
import { msw, mswListVersions } from "../helpers/msw";
Expand Down Expand Up @@ -27,11 +28,9 @@ describe("versions list", () => {

expect(std.out).toMatchInlineSnapshot(`""`);

expect(std.err).toMatchInlineSnapshot(`
"X [ERROR] You need to provide a name when deploying a worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = \\"<name>\\"\`
"
`);
expect(normalizeOutput(std.err)).toMatchInlineSnapshot(
`"X [ERROR] You need to provide a name when deploying a worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = \\"<name>\\"\`"`
);
});

test("prints versions to stdout", async () => {
Expand Down
47 changes: 32 additions & 15 deletions packages/wrangler/src/__tests__/versions/versions.view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ describe("versions view", () => {
`[Error: Not enough non-option arguments: got 0, need at least 1]`
);

expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
"wrangler versions view <version-id>
expect(std.out).toMatchInlineSnapshot(`
"
wrangler versions view <version-id>
View the details of a specific version of your Worker [beta]
Positionals:
version-id The Worker Version ID to view [string] [required]
Flags:
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
-c, --config Path to .toml configuration file [string]
-e, --env Environment to use for operations and .env files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--name Name of the worker [string]"
`);
Expand All @@ -55,17 +60,22 @@ describe("versions view", () => {
`[Error: Not enough non-option arguments: got 0, need at least 1]`
);

expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
"wrangler versions view <version-id>
expect(std.out).toMatchInlineSnapshot(`
"
wrangler versions view <version-id>
View the details of a specific version of your Worker [beta]
Positionals:
version-id The Worker Version ID to view [string] [required]
Flags:
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
-c, --config Path to .toml configuration file [string]
-e, --env Environment to use for operations and .env files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--name Name of the worker [string]"
`);
Expand All @@ -84,7 +94,7 @@ describe("versions view", () => {
`[Error: You need to provide a name when deploying a worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = "<name>"\`]`
);

expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`""`);
expect(std.out).toMatchInlineSnapshot(`""`);

expect(normalizeOutput(std.err)).toMatchInlineSnapshot(
`"X [ERROR] You need to provide a name when deploying a worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = \\"<name>\\"\`"`
Expand All @@ -98,13 +108,14 @@ describe("versions view", () => {

await expect(result).resolves.toBeUndefined();

expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
"Version ID: 00000000-0000-0000-0000-000000000000
Created: 1/1/2021, TIMESTAMP AM
expect(std.out).toMatchInlineSnapshot(`
"Version ID: 10000000-0000-0000-0000-000000000000
Created: 1/1/2021, 12:00:00 AM
Author: Jean-Luc-Picard@federation.org
Source: wrangler
Tag: -
Message: -"
Message: -
"
`);

expect(normalizeOutput(std.err)).toMatchInlineSnapshot(`""`);
Expand All @@ -123,17 +134,22 @@ describe("versions view", () => {
`[Error: Not enough non-option arguments: got 0, need at least 1]`
);

expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
"wrangler versions view <version-id>
expect(std.out).toMatchInlineSnapshot(`
"
wrangler versions view <version-id>
View the details of a specific version of your Worker [beta]
Positionals:
version-id The Worker Version ID to view [string] [required]
Flags:
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
-c, --config Path to .toml configuration file [string]
-e, --env Environment to use for operations and .env files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--name Name of the worker [string]"
`);
Expand All @@ -150,13 +166,14 @@ describe("versions view", () => {

await expect(result).resolves.toBeUndefined();

expect(normalizeOutput(std.out)).toMatchInlineSnapshot(`
"Version ID: 00000000-0000-0000-0000-000000000000
Created: 1/1/2021, TIMESTAMP AM
expect(std.out).toMatchInlineSnapshot(`
"Version ID: 10000000-0000-0000-0000-000000000000
Created: 1/1/2021, 12:00:00 AM
Author: Jean-Luc-Picard@federation.org
Source: wrangler
Tag: -
Message: -"
Message: -
"
`);

expect(normalizeOutput(std.err)).toMatchInlineSnapshot(`""`);
Expand Down

0 comments on commit e6d37d5

Please sign in to comment.