diff --git a/test/__tests__/__snapshots__/arg-parsing.js.snap b/test/__tests__/__snapshots__/arg-parsing.js.snap index 3924dc8..5873143 100644 --- a/test/__tests__/__snapshots__/arg-parsing.js.snap +++ b/test/__tests__/__snapshots__/arg-parsing.js.snap @@ -1,69 +1,86 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`allow overriding flags (stderr) 1`] = `""`; - -exports[`allow overriding flags (write) 1`] = `[]`; - -exports[`boolean flags do not swallow the next argument (stderr) 1`] = `""`; - -exports[`boolean flags do not swallow the next argument (stdout) 1`] = `"console.log('could be single quote and without semi');"`; - -exports[`boolean flags do not swallow the next argument (write) 1`] = `[]`; - -exports[`negated options work (stderr) 1`] = `""`; +exports[`allow overriding flags 1`] = ` +{ + "stderr": "", + "write": [], +} +`; -exports[`negated options work (stdout) 1`] = `"console.log("could be single quote and without semi")"`; +exports[`boolean flags do not swallow the next argument 1`] = ` +{ + "stderr": "", + "stdout": "console.log('could be single quote and without semi');", + "write": [], +} +`; -exports[`negated options work (write) 1`] = `[]`; +exports[`negated options work 1`] = ` +{ + "stderr": "", + "stdout": "console.log("could be single quote and without semi")", + "write": [], +} +`; -exports[`number file/dir (stdout) 1`] = `"1/file-in-dir-named-1.js"`; +exports[`number file/dir 1`] = ` +{ + "stdout": "1/file-in-dir-named-1.js", +} +`; -exports[`number file/dir (stdout) 2`] = `"2.2/file-in-dir-named-2.2.js"`; +exports[`number file/dir 2`] = ` +{ + "stdout": "2.2/file-in-dir-named-2.2.js", +} +`; -exports[`number file/dir (stdout) 3`] = `"3"`; +exports[`number file/dir 3`] = ` +{ + "stdout": "3", +} +`; -exports[`number file/dir (stdout) 4`] = `"4.44"`; +exports[`number file/dir 4`] = ` +{ + "stdout": "4.44", +} +`; -exports[`number file/dir (stdout) 5`] = ` -"1/file-in-dir-named-1.js +exports[`number file/dir 5`] = ` +{ + "stdout": "1/file-in-dir-named-1.js 2.2/file-in-dir-named-2.2.js 3 -4.44" -`; - -exports[`options with \`cliName\` should not allow to pass directly (stderr) 1`] = ` -"[warn] Ignored unknown option --filepath=file.js. -[error] No parser and no file path given, couldn't infer a parser." +4.44", +} `; -exports[`options with \`cliName\` should not allow to pass directly (stdout) 1`] = `"prettier();"`; - -exports[`options with \`cliName\` should not allow to pass directly (stdout) 2`] = `""`; - -exports[`unknown negated options are errored (stderr) 1`] = ` -" +exports[`unknown negated options are errored 1`] = ` +{ + "stderr": " Unknown option: "unknown" -" +", + "stdout": "", + "write": [], +} `; -exports[`unknown negated options are errored (stdout) 1`] = `""`; - -exports[`unknown negated options are errored (write) 1`] = `[]`; - -exports[`unknown options are errored (stderr) 1`] = ` -" +exports[`unknown options are errored 1`] = ` +{ + "stderr": " Unknown option: "unknown" -" +", + "stdout": "", + "write": [], +} `; -exports[`unknown options are errored (stdout) 1`] = `""`; - -exports[`unknown options are errored (write) 1`] = `[]`; - -exports[`unknown options may trigger a suggestion \`_\` (stderr) 1`] = ` -" +exports[`unknown options may trigger a suggestion \`_\` 1`] = ` +{ + "stderr": " Unknown option: "a". Did you mean "v"? -" +", + "stdout": "", +} `; - -exports[`unknown options may trigger a suggestion \`_\` (stdout) 1`] = `""`; diff --git a/test/__tests__/__snapshots__/check.js.snap b/test/__tests__/__snapshots__/check.js.snap index 4267983..5c4ab15 100644 --- a/test/__tests__/__snapshots__/check.js.snap +++ b/test/__tests__/__snapshots__/check.js.snap @@ -1,33 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`--checks should print the number of files that need formatting (stderr) 1`] = ` -"[warn] unformatted.js +exports[`--checks should print the number of files that need formatting 1`] = ` +{ + "stderr": "[warn] unformatted.js [warn] unformatted2.js -[warn] Code style issues found in 2 files. Run Prettier with --write to fix." +[warn] Code style issues found in 2 files. Run Prettier with --write to fix.", + "stdout": "Checking formatting...", + "write": [], +} `; -exports[`--checks should print the number of files that need formatting (stdout) 1`] = `"Checking formatting..."`; - -exports[`--checks should print the number of files that need formatting (write) 1`] = `[]`; - -exports[`--checks works in CI just as in a non-TTY mode (stderr) 1`] = ` -"[warn] unformatted.js -[warn] Code style issues found in 1 file. Run Prettier with --write to fix." +exports[`--checks works in CI just as in a non-TTY mode 1`] = ` +{ + "stderr": "[warn] unformatted.js +[warn] Code style issues found in 1 file. Run Prettier with --write to fix.", + "stdout": "Checking formatting...", + "write": [], +} `; -exports[`--checks works in CI just as in a non-TTY mode (stderr) 2`] = ` -"[warn] unformatted.js -[warn] Code style issues found in 1 file. Run Prettier with --write to fix." +exports[`--checks works in CI just as in a non-TTY mode 2`] = ` +{ + "stderr": "[warn] unformatted.js +[warn] Code style issues found in 1 file. Run Prettier with --write to fix.", + "stdout": "Checking formatting...", + "write": [], +} `; -exports[`--checks works in CI just as in a non-TTY mode (stdout) 1`] = `"Checking formatting..."`; - -exports[`--checks works in CI just as in a non-TTY mode (stdout) 2`] = `"Checking formatting..."`; - -exports[`--checks works in CI just as in a non-TTY mode (write) 1`] = `[]`; - -exports[`--checks works in CI just as in a non-TTY mode (write) 2`] = `[]`; - -exports[`checks stdin with --check (write) 1`] = `[]`; +exports[`checks stdin with --check 1`] = ` +{ + "write": [], +} +`; -exports[`checks stdin with -c (alias for --check) (write) 1`] = `[]`; +exports[`checks stdin with -c (alias for --check) 1`] = ` +{ + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/cursor-offset.js.snap b/test/__tests__/__snapshots__/cursor-offset.js.snap index bdc1314..a0c2b2f 100644 --- a/test/__tests__/__snapshots__/cursor-offset.js.snap +++ b/test/__tests__/__snapshots__/cursor-offset.js.snap @@ -1,7 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`cursorOffset should not be affected by full-width character (stdout) 1`] = ` -"const x = [ +exports[`cursorOffset should not be affected by full-width character 1`] = ` +{ + "stdout": "const x = [ "中文", "中文", "中文", @@ -13,13 +14,15 @@ exports[`cursorOffset should not be affected by full-width character (stdout) 1` "中文", "中文", "中文", -];" +];", + "write": [], +} `; -exports[`cursorOffset should not be affected by full-width character (write) 1`] = `[]`; - -exports[`write cursorOffset to stderr with --cursor-offset (stderr) 1`] = `"1"`; - -exports[`write cursorOffset to stderr with --cursor-offset (stdout) 1`] = `"1;"`; - -exports[`write cursorOffset to stderr with --cursor-offset (write) 1`] = `[]`; +exports[`write cursorOffset to stderr with --cursor-offset 1`] = ` +{ + "stderr": "1", + "stdout": "1;", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/early-exit.js.snap b/test/__tests__/__snapshots__/early-exit.js.snap index 214fca3..6f53037 100644 --- a/test/__tests__/__snapshots__/early-exit.js.snap +++ b/test/__tests__/__snapshots__/early-exit.js.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`show usage with --help (stderr) 1`] = `""`; - -exports[`show usage with --help (stdout) 1`] = ` -" +exports[`show usage with --help 1`] = ` +{ + "stderr": "", + "stdout": " prettier 3.3.3 USAGE @@ -131,81 +131,84 @@ exports[`show usage with --help (stdout) 1`] = ` --require-pragma Require either "@prettier" or "@format" to be present in the file's first docblock comment in order for it to be formatted Defaults to "false" --stdin-filepath Path to the file to pretend that stdin comes from - " + ", + "write": [], +} `; -exports[`show usage with --help (write) 1`] = `[]`; - -exports[`show version with --version (stderr) 1`] = `""`; - -exports[`show version with --version (write) 1`] = `[]`; +exports[`show version with --version 1`] = ` +{ + "stderr": "", + "write": [], +} +`; -exports[`throw error with --check + --list-different (stderr) 1`] = ` -" +exports[`throw error with --check + --list-different 1`] = ` +{ + "stderr": " Incompatible options: "check" and "list-different" cannot be used together -" +", + "stdout": "", + "write": [], +} `; -exports[`throw error with --check + --list-different (stdout) 1`] = `""`; - -exports[`throw error with --check + --list-different (write) 1`] = `[]`; - -exports[`throw error with --check + --write (stderr) 1`] = ` -" +exports[`throw error with --check + --write 1`] = ` +{ + "stderr": " Incompatible options: "check" and "write" cannot be used together -" +", + "stdout": "", + "write": [], +} `; -exports[`throw error with --check + --write (stdout) 1`] = `""`; - -exports[`throw error with --check + --write (write) 1`] = `[]`; - -exports[`throw error with --list-different + --write (stderr) 1`] = ` -" +exports[`throw error with --list-different + --write 1`] = ` +{ + "stderr": " Incompatible options: "list-different" and "write" cannot be used together -" +", + "stdout": "", + "write": [], +} `; -exports[`throw error with --list-different + --write (stdout) 1`] = `""`; - -exports[`throw error with --list-different + --write (write) 1`] = `[]`; - -exports[`throw error with something unexpected (stderr) 1`] = ` -" +exports[`throw error with something unexpected 1`] = ` +{ + "stderr": " Expected at least one target file/dir/glob -" +", + "stdout": "", + "write": [], +} `; -exports[`throw error with something unexpected (stdout) 1`] = `""`; - -exports[`throw error with something unexpected (write) 1`] = `[]`; - -exports[`throw unsupported error with --file-info (stderr) 1`] = ` -" +exports[`throw unsupported error with --file-info 1`] = ` +{ + "stderr": " The "--file-info" option is not currently supported, please open an issue on GitHub if you need it -" +", + "stdout": "", + "write": [], +} `; -exports[`throw unsupported error with --file-info (stdout) 1`] = `""`; - -exports[`throw unsupported error with --file-info (write) 1`] = `[]`; - -exports[`throw unsupported error with --find-config-path (stderr) 1`] = ` -" +exports[`throw unsupported error with --find-config-path 1`] = ` +{ + "stderr": " Unknown option: "find-config-path" -" +", + "stdout": "", + "write": [], +} `; -exports[`throw unsupported error with --find-config-path (stdout) 1`] = `""`; - -exports[`throw unsupported error with --find-config-path (write) 1`] = `[]`; - -exports[`throw unsupported error with --support-info (stderr) 1`] = ` -" +exports[`throw unsupported error with --support-info 1`] = ` +{ + "stderr": " The "--support-info" option is not currently supported, please open an issue on GitHub if you need it -" +", + "stdout": "", + "write": [], +} `; - -exports[`throw unsupported error with --support-info (stdout) 1`] = `""`; - -exports[`throw unsupported error with --support-info (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap b/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap index 327d815..d0d5bff 100644 --- a/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap +++ b/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap @@ -1,37 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`error on unmatched pattern (stderr) 1`] = `"[error] No files matching the given patterns were found."`; - -exports[`error on unmatched pattern (stdout) 1`] = `""`; - -exports[`error on unmatched pattern (write) 1`] = `[]`; - -exports[`error on unmatched pattern when 2nd glob has no match, by default (stderr) 1`] = `""`; +exports[`error on unmatched pattern 1`] = ` +{ + "stderr": "[error] No files matching the given patterns were found.", + "stdout": "", + "write": [], +} +`; -exports[`error on unmatched pattern when 2nd glob has no match, by default (stdout) 1`] = ` -"const hello = "there"; +exports[`error on unmatched pattern when 2nd glob has no match, by default 1`] = ` +{ + "stderr": "", + "stdout": "const hello = "there"; { "hello": "there" } -hello: there" +hello: there", + "write": [], +} `; -exports[`error on unmatched pattern when 2nd glob has no match, by default (write) 1`] = `[]`; - -exports[`no error on unmatched pattern (stderr) 1`] = `""`; - -exports[`no error on unmatched pattern (stdout) 1`] = `"const hello = "there";"`; - -exports[`no error on unmatched pattern (write) 1`] = `[]`; - -exports[`no error on unmatched pattern when 2nd glob has no match, with flag (stderr) 1`] = `""`; +exports[`no error on unmatched pattern 1`] = ` +{ + "stderr": "", + "stdout": "const hello = "there";", + "write": [], +} +`; -exports[`no error on unmatched pattern when 2nd glob has no match, with flag (stdout) 1`] = ` -"const hello = "there"; +exports[`no error on unmatched pattern when 2nd glob has no match, with flag 1`] = ` +{ + "stderr": "", + "stdout": "const hello = "there"; { "hello": "there" } -hello: there" +hello: there", + "write": [], +} `; - -exports[`no error on unmatched pattern when 2nd glob has no match, with flag (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/ignore-absolute-path.js.snap b/test/__tests__/__snapshots__/ignore-absolute-path.js.snap index bf1f4a6..2e6692d 100644 --- a/test/__tests__/__snapshots__/ignore-absolute-path.js.snap +++ b/test/__tests__/__snapshots__/ignore-absolute-path.js.snap @@ -1,7 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`support absolute filename (stderr) 1`] = `""`; - -exports[`support absolute filename (stdout) 1`] = `"regular-module.js"`; - -exports[`support absolute filename (write) 1`] = `[]`; +exports[`support absolute filename 1`] = ` +{ + "stderr": "", + "stdout": "regular-module.js", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/ignore-emoji.js.snap b/test/__tests__/__snapshots__/ignore-emoji.js.snap index 51dddc3..5fd372c 100644 --- a/test/__tests__/__snapshots__/ignore-emoji.js.snap +++ b/test/__tests__/__snapshots__/ignore-emoji.js.snap @@ -1,13 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ignores file name contains emoji (stderr) 1`] = `""`; - -exports[`ignores file name contains emoji (stdout) 1`] = `"not-ignored.js"`; - -exports[`ignores file name contains emoji (write) 1`] = `[]`; - -exports[`stdin (stderr) 1`] = `""`; - -exports[`stdin (stdout) 1`] = `".name { display: none; }"`; - -exports[`stdin (write) 1`] = `[]`; +exports[`ignores file name contains emoji 1`] = ` +{ + "stderr": "", + "stdout": "not-ignored.js", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/ignore-folder.js.snap b/test/__tests__/__snapshots__/ignore-folder.js.snap index 930f12a..1c15942 100644 --- a/test/__tests__/__snapshots__/ignore-folder.js.snap +++ b/test/__tests__/__snapshots__/ignore-folder.js.snap @@ -1,17 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ignores files in ignored folders (stderr) 1`] = `""`; - -exports[`ignores files in ignored folders (stdout) 1`] = `"not-ignored.js"`; - -exports[`ignores files in ignored folders (write) 1`] = `[]`; - -exports[`ignores ignore files when processing stdin (stderr) 1`] = `""`; +exports[`ignores files in ignored folders 1`] = ` +{ + "stderr": "", + "stdout": "not-ignored.js", + "write": [], +} +`; -exports[`ignores ignore files when processing stdin (stdout) 1`] = ` -".name { +exports[`ignores ignore files when processing stdin 1`] = ` +{ + "stderr": "", + "stdout": ".name { display: none; -}" +}", + "write": [], +} `; - -exports[`ignores ignore files when processing stdin (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/ignore-in-subdirectories.js.snap b/test/__tests__/__snapshots__/ignore-in-subdirectories.js.snap index 49a61e6..1b5e105 100644 --- a/test/__tests__/__snapshots__/ignore-in-subdirectories.js.snap +++ b/test/__tests__/__snapshots__/ignore-in-subdirectories.js.snap @@ -1,33 +1,47 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`formats files when executing in a subdirectory (stderr) 1`] = `""`; - -exports[`formats files when executing in a subdirectory (stderr) 2`] = `""`; - -exports[`formats files when executing in a subdirectory (stdout) 1`] = `"should-not-ignore.js"`; - -exports[`formats files when executing in a subdirectory (stdout) 2`] = `"should-not-ignore.js"`; - -exports[`formats files when executing in a subdirectory (write) 1`] = `[]`; - -exports[`formats files when executing in a subdirectory (write) 2`] = `[]`; - -exports[`formats files when executing in a subdirectory and using stdin (stderr) 1`] = `""`; - -exports[`formats files when executing in a subdirectory and using stdin (write) 1`] = `[]`; - -exports[`ignore files when executing in a subdirectory and using stdin (stderr) 1`] = `""`; - -exports[`ignore files when executing in a subdirectory and using stdin (write) 1`] = `[]`; - -exports[`ignores files when executing in a subdirectory (stderr) 1`] = `""`; - -exports[`ignores files when executing in a subdirectory (stderr) 2`] = `""`; - -exports[`ignores files when executing in a subdirectory (stdout) 1`] = `""`; - -exports[`ignores files when executing in a subdirectory (stdout) 2`] = `""`; - -exports[`ignores files when executing in a subdirectory (write) 1`] = `[]`; - -exports[`ignores files when executing in a subdirectory (write) 2`] = `[]`; +exports[`formats files when executing in a subdirectory 1`] = ` +{ + "stderr": "", + "stdout": "should-not-ignore.js", + "write": [], +} +`; + +exports[`formats files when executing in a subdirectory 2`] = ` +{ + "stderr": "", + "stdout": "should-not-ignore.js", + "write": [], +} +`; + +exports[`formats files when executing in a subdirectory and using stdin 1`] = ` +{ + "stderr": "", + "write": [], +} +`; + +exports[`ignore files when executing in a subdirectory and using stdin 1`] = ` +{ + "stderr": "", + "write": [], +} +`; + +exports[`ignores files when executing in a subdirectory 1`] = ` +{ + "stderr": "", + "stdout": "", + "write": [], +} +`; + +exports[`ignores files when executing in a subdirectory 2`] = ` +{ + "stderr": "", + "stdout": "", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/ignore-relative-path.js.snap b/test/__tests__/__snapshots__/ignore-relative-path.js.snap index 28dc1c3..09bd26f 100644 --- a/test/__tests__/__snapshots__/ignore-relative-path.js.snap +++ b/test/__tests__/__snapshots__/ignore-relative-path.js.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`support relative paths (stderr) 1`] = `""`; - -exports[`support relative paths (stdout) 1`] = ` -"level1-glob/level2-glob/level3-glob/shouldNotBeIgnored.scss +exports[`support relative paths 1`] = ` +{ + "stderr": "", + "stdout": "level1-glob/level2-glob/level3-glob/shouldNotBeIgnored.scss level1-glob/shouldNotBeIgnored.js -shouldNotBeIgnored.js" +shouldNotBeIgnored.js", + "write": [], +} `; - -exports[`support relative paths (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/ignore-unknown.js.snap b/test/__tests__/__snapshots__/ignore-unknown.js.snap index 247fef9..72c4004 100644 --- a/test/__tests__/__snapshots__/ignore-unknown.js.snap +++ b/test/__tests__/__snapshots__/ignore-unknown.js.snap @@ -1,64 +1,75 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Ignored file (stderr) 1`] = `""`; - -exports[`Ignored file (stdout) 1`] = `""`; - -exports[`Ignored file (write) 1`] = `[]`; - -exports[`None exist file (stderr) 1`] = `"[error] No files matching the given patterns were found."`; - -exports[`None exist file (stdout) 1`] = `""`; - -exports[`None exist file (write) 1`] = `[]`; - -exports[`Not matching pattern (stderr) 1`] = `"[error] No files matching the given patterns were found."`; - -exports[`Not matching pattern (stdout) 1`] = `""`; - -exports[`Not matching pattern (write) 1`] = `[]`; - -exports[`ignore-unknown alias (stdout) 1`] = ` -"javascript.js -override.as-js-file" +exports[`Ignored file 1`] = ` +{ + "stderr": "", + "stdout": "", + "write": [], +} `; -exports[`ignore-unknown check (stderr) 1`] = ` -"[warn] javascript.js -[warn] override.as-js-file -[warn] Code style issues found in 2 files. Run Prettier with --write to fix." +exports[`None exist file 1`] = ` +{ + "stderr": "[error] No files matching the given patterns were found.", + "stdout": "", + "write": [], +} `; -exports[`ignore-unknown check (stdout) 1`] = `"Checking formatting..."`; +exports[`Not matching pattern 1`] = ` +{ + "stderr": "[error] No files matching the given patterns were found.", + "stdout": "", + "write": [], +} +`; -exports[`ignore-unknown check (write) 1`] = `[]`; +exports[`ignore-unknown alias 1`] = ` +{ + "stdout": "javascript.js +override.as-js-file", +} +`; -exports[`ignore-unknown dir (stdout) 1`] = ` -"javascript.js -override.as-js-file" +exports[`ignore-unknown check 1`] = ` +{ + "stderr": "[warn] javascript.js +[warn] override.as-js-file +[warn] Code style issues found in 2 files. Run Prettier with --write to fix.", + "stdout": "Checking formatting...", + "write": [], +} `; -exports[`ignore-unknown pattern (stdout) 1`] = ` -"javascript.js -override.as-js-file" +exports[`ignore-unknown dir 1`] = ` +{ + "stdout": "javascript.js +override.as-js-file", +} `; -exports[`ignore-unknown write (stdout) 1`] = ` -"javascript.js -override.as-js-file" +exports[`ignore-unknown pattern 1`] = ` +{ + "stdout": "javascript.js +override.as-js-file", +} `; -exports[`ignore-unknown write (write) 1`] = ` -[ - { - "content": "const foo = "bar"; +exports[`ignore-unknown write 1`] = ` +{ + "stdout": "javascript.js +override.as-js-file", + "write": [ + { + "content": "const foo = "bar"; ", - "filename": "javascript.js", - }, - { - "content": "const foo = "bar"; + "filename": "javascript.js", + }, + { + "content": "const foo = "bar"; ", - "filename": "override.as-js-file", - }, -] + "filename": "override.as-js-file", + }, + ], +} `; diff --git a/test/__tests__/__snapshots__/ignore-vcs-files.js.snap b/test/__tests__/__snapshots__/ignore-vcs-files.js.snap index b103cd4..e9687e7 100644 --- a/test/__tests__/__snapshots__/ignore-vcs-files.js.snap +++ b/test/__tests__/__snapshots__/ignore-vcs-files.js.snap @@ -1,17 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`does not ignore files in version control systems, if manually provided (stderr) 1`] = `""`; - -exports[`does not ignore files in version control systems, if manually provided (stdout) 1`] = ` -".hg/file.js +exports[`does not ignore files in version control systems, if manually provided 1`] = ` +{ + "stderr": "", + "stdout": ".hg/file.js .svn/file.js -file.js" +file.js", + "write": [], +} `; -exports[`does not ignore files in version control systems, if manually provided (write) 1`] = `[]`; - -exports[`ignores files in version control systems, if discovered (stderr) 1`] = `""`; - -exports[`ignores files in version control systems, if discovered (stdout) 1`] = `"file.js"`; - -exports[`ignores files in version control systems, if discovered (write) 1`] = `[]`; +exports[`ignores files in version control systems, if discovered 1`] = ` +{ + "stderr": "", + "stdout": "file.js", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/invalid-ignore.js.snap b/test/__tests__/__snapshots__/invalid-ignore.js.snap index 7ce471b..75c29f0 100644 --- a/test/__tests__/__snapshots__/invalid-ignore.js.snap +++ b/test/__tests__/__snapshots__/invalid-ignore.js.snap @@ -1,7 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ignores .prettierignore folder (stderr) 1`] = `""`; - -exports[`ignores .prettierignore folder (stdout) 1`] = `""`; - -exports[`ignores .prettierignore folder (write) 1`] = `[]`; +exports[`ignores .prettierignore folder 1`] = ` +{ + "stderr": "", + "stdout": "", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/list-different.js.snap b/test/__tests__/__snapshots__/list-different.js.snap index a751bdf..57e5998 100644 --- a/test/__tests__/__snapshots__/list-different.js.snap +++ b/test/__tests__/__snapshots__/list-different.js.snap @@ -1,17 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`--list-different works in CI just as in a non-TTY mode (stderr) 1`] = `""`; - -exports[`--list-different works in CI just as in a non-TTY mode (stderr) 2`] = `""`; - -exports[`--list-different works in CI just as in a non-TTY mode (stdout) 1`] = `"unformatted.js"`; - -exports[`--list-different works in CI just as in a non-TTY mode (stdout) 2`] = `"unformatted.js"`; - -exports[`--list-different works in CI just as in a non-TTY mode (write) 1`] = `[]`; - -exports[`--list-different works in CI just as in a non-TTY mode (write) 2`] = `[]`; - -exports[`checks stdin with --list-different (write) 1`] = `[]`; - -exports[`checks stdin with -l (alias for --list-different) (write) 1`] = `[]`; +exports[`--list-different works in CI just as in a non-TTY mode 1`] = ` +{ + "stderr": "", + "stdout": "unformatted.js", + "write": [], +} +`; + +exports[`--list-different works in CI just as in a non-TTY mode 2`] = ` +{ + "stderr": "", + "stdout": "unformatted.js", + "write": [], +} +`; + +exports[`checks stdin with --list-different 1`] = ` +{ + "write": [], +} +`; + +exports[`checks stdin with -l (alias for --list-different) 1`] = ` +{ + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/patterns-glob.js.snap b/test/__tests__/__snapshots__/patterns-glob.js.snap index 510a4c6..7a53642 100644 --- a/test/__tests__/__snapshots__/patterns-glob.js.snap +++ b/test/__tests__/__snapshots__/patterns-glob.js.snap @@ -1,104 +1,116 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`fixtures-1: Should match all files (stderr) 1`] = `""`; - -exports[`fixtures-1: Should match all files (stdout) 1`] = ` -"!file.js +exports[`fixtures-1: Should match all files 1`] = ` +{ + "stderr": "", + "stdout": "!file.js a.js -b.js" +b.js", + "write": [], +} `; -exports[`fixtures-1: Should match all files (write) 1`] = `[]`; - -exports[`fixtures-1: Should match files except \`a.js\` (stderr) 1`] = `""`; - -exports[`fixtures-1: Should match files except \`a.js\` (stdout) 1`] = ` -"!file.js -b.js" +exports[`fixtures-1: Should match files except \`a.js\` 1`] = ` +{ + "stderr": "", + "stdout": "!file.js +b.js", + "write": [], +} `; -exports[`fixtures-1: Should match files except \`a.js\` (write) 1`] = `[]`; - -exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` (stderr) 1`] = `""`; - -exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` (stdout) 1`] = ` -"!b.js -a.js" +exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` 1`] = ` +{ + "stderr": "", + "stdout": "!b.js +a.js", + "write": [], +} `; -exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` (write) 1`] = `[]`; - -exports[`fixtures-2: Should match all js files and all supported files in the '!dir.js' directory (stderr) 1`] = `""`; - -exports[`fixtures-2: Should match all js files and all supported files in the '!dir.js' directory (stdout) 1`] = ` -"!b.js +exports[`fixtures-2: Should match all js files and all supported files in the '!dir.js' directory 1`] = ` +{ + "stderr": "", + "stdout": "!b.js !dir.js/1.css !dir.js/2.css -a.js" +a.js", + "write": [], +} `; -exports[`fixtures-2: Should match all js files and all supported files in the '!dir.js' directory (write) 1`] = `[]`; - -exports[`fixtures-2: Should only match \`!b.js\` (stderr) 1`] = `""`; - -exports[`fixtures-2: Should only match \`!b.js\` (stdout) 1`] = `"!b.js"`; - -exports[`fixtures-2: Should only match \`!b.js\` (write) 1`] = `[]`; - -exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` (stderr) 1`] = `""`; +exports[`fixtures-2: Should only match \`!b.js\` 1`] = ` +{ + "stderr": "", + "stdout": "!b.js", + "write": [], +} +`; -exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` (stdout) 1`] = ` -"dir/inside.js +exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` 1`] = ` +{ + "stderr": "", + "stdout": "dir/inside.js dir/node_modules/in-node_modules.js -outside.js" +outside.js", + "write": [], +} `; -exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` (write) 1`] = `[]`; - -exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (existing) (stderr) 1`] = `""`; - -exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (existing) (stdout) 1`] = ` -"dir/.svn/in-svn.js -outside.js" +exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (existing) 1`] = ` +{ + "stderr": "", + "stdout": "dir/.svn/in-svn.js +outside.js", + "write": [], +} `; -exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (existing) (write) 1`] = `[]`; - -exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (nonexisting) (stderr) 1`] = `""`; - -exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (nonexisting) (stdout) 1`] = `"outside.js"`; - -exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (nonexisting) (write) 1`] = `[]`; - -exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` (stderr) 1`] = `""`; - -exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` (stdout) 1`] = ` -"dir/inside.js -outside.js" +exports[`fixtures-3: Should not exclude \`.svn\` when specified explicitly (nonexisting) 1`] = ` +{ + "stderr": "", + "stdout": "outside.js", + "write": [], +} `; -exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` (write) 1`] = `[]`; - -exports[`fixtures-4: Should match \`level-1.js\` #2 (stderr) 1`] = `""`; - -exports[`fixtures-4: Should match \`level-1.js\` #2 (stdout) 1`] = `"0/level-1.js"`; - -exports[`fixtures-4: Should match \`level-1.js\` #2 (write) 1`] = `[]`; - -exports[`fixtures-4: Should match \`level-1.js\` #3 (stderr) 1`] = `""`; - -exports[`fixtures-4: Should match \`level-1.js\` #3 (stdout) 1`] = `"0/level-1.js"`; - -exports[`fixtures-4: Should match \`level-1.js\` #3 (write) 1`] = `[]`; - -exports[`fixtures-4: Should match \`level-1.js\` (stderr) 1`] = `""`; - -exports[`fixtures-4: Should match \`level-1.js\` (stdout) 1`] = `"0/level-1.js"`; +exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` 1`] = ` +{ + "stderr": "", + "stdout": "dir/inside.js +outside.js", + "write": [], +} +`; -exports[`fixtures-4: Should match \`level-1.js\` (write) 1`] = `[]`; +exports[`fixtures-4: Should match \`level-1.js\` 1`] = ` +{ + "stderr": "", + "stdout": "0/level-1.js", + "write": [], +} +`; -exports[`should not ignore file paths contains object prototype keys (stderr) 1`] = `""`; +exports[`fixtures-4: Should match \`level-1.js\` #2 1`] = ` +{ + "stderr": "", + "stdout": "0/level-1.js", + "write": [], +} +`; -exports[`should not ignore file paths contains object prototype keys (stdout) 1`] = `"constructor/should-be-formatted.js"`; +exports[`fixtures-4: Should match \`level-1.js\` #3 1`] = ` +{ + "stderr": "", + "stdout": "0/level-1.js", + "write": [], +} +`; -exports[`should not ignore file paths contains object prototype keys (write) 1`] = `[]`; +exports[`should not ignore file paths contains object prototype keys 1`] = ` +{ + "stderr": "", + "stdout": "constructor/should-be-formatted.js", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/patterns.js.snap b/test/__tests__/__snapshots__/patterns.js.snap index d2bc8ff..cd89e65 100644 --- a/test/__tests__/__snapshots__/patterns.js.snap +++ b/test/__tests__/__snapshots__/patterns.js.snap @@ -1,82 +1,73 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`exits with an informative message when there are no patterns provided (stderr) 1`] = ` -" +exports[`exits with an informative message when there are no patterns provided 1`] = ` +{ + "stderr": " Expected at least one target file/dir/glob -" +", + "stdout": "", + "write": [], +} `; -exports[`exits with an informative message when there are no patterns provided (stdout) 1`] = `""`; - -exports[`exits with an informative message when there are no patterns provided (write) 1`] = `[]`; - -exports[`multiple patterns (stderr) 1`] = `""`; - -exports[`multiple patterns (stdout) 1`] = ` -"directory/file.js +exports[`multiple patterns 1`] = ` +{ + "stderr": "", + "stdout": "directory/file.js directory/nested-directory/nested-directory-file.js other-directory/file.js -other-directory/nested-directory/nested-directory-file.js" +other-directory/nested-directory/nested-directory-file.js", + "write": [], +} `; -exports[`multiple patterns (write) 1`] = `[]`; - -exports[`multiple patterns with a negated pattern (stderr) 1`] = `""`; - -exports[`multiple patterns with a negated pattern (stdout) 1`] = ` -"directory/file.js +exports[`multiple patterns with a negated pattern 1`] = ` +{ + "stderr": "", + "stdout": "directory/file.js other-directory/file.js other-regular-modules.js -regular-module.js" -`; - -exports[`multiple patterns with a negated pattern (write) 1`] = `[]`; - -exports[`multiple patterns with a negated pattern and leading \`./\`, ignores node_modules by default (stderr) 1`] = `""`; - -exports[`multiple patterns with a negated pattern and leading \`./\`, ignores node_modules by default (stdout) 1`] = ` -"other-directory/file.js -other-directory/nested-directory/nested-directory-file.js -other-regular-modules.js -regular-module.js" +regular-module.js", + "write": [], +} `; -exports[`multiple patterns with a negated pattern and leading \`./\`, ignores node_modules by default (write) 1`] = `[]`; - -exports[`multiple patterns with a negated pattern, doesn't ignore node_modules with the --with-node-modules flag (stderr) 1`] = `""`; - -exports[`multiple patterns with a negated pattern, doesn't ignore node_modules with the --with-node-modules flag (stdout) 1`] = ` -"node_modules/node-module.js +exports[`multiple patterns with a negated pattern, doesn't ignore node_modules with the --with-node-modules flag 1`] = ` +{ + "stderr": "", + "stdout": "node_modules/node-module.js other-directory/file.js other-directory/nested-directory/nested-directory-file.js other-regular-modules.js -regular-module.js" +regular-module.js", + "write": [], +} `; -exports[`multiple patterns with a negated pattern, doesn't ignore node_modules with the --with-node-modules flag (write) 1`] = `[]`; - -exports[`multiple patterns with a negated pattern, ignores node_modules by default (stderr) 1`] = `""`; - -exports[`multiple patterns with a negated pattern, ignores node_modules by default (stdout) 1`] = ` -"other-directory/file.js +exports[`multiple patterns with a negated pattern, ignores node_modules by default 1`] = ` +{ + "stderr": "", + "stdout": "other-directory/file.js other-directory/nested-directory/nested-directory-file.js other-regular-modules.js -regular-module.js" +regular-module.js", + "write": [], +} `; -exports[`multiple patterns with a negated pattern, ignores node_modules by default (write) 1`] = `[]`; - -exports[`multiple patterns with an extra non-existent pattern (stderr) 1`] = `""`; - -exports[`multiple patterns with an extra non-existent pattern (stdout) 1`] = ` -"directory/file.js -directory/nested-directory/nested-directory-file.js" +exports[`multiple patterns with an extra non-existent pattern 1`] = ` +{ + "stderr": "", + "stdout": "directory/file.js +directory/nested-directory/nested-directory-file.js", + "write": [], +} `; -exports[`multiple patterns with an extra non-existent pattern (write) 1`] = `[]`; - -exports[`multiple patterns, throws an error and exits with a non-zero code when there are no matches (stderr) 1`] = `"[error] No files matching the given patterns were found."`; - -exports[`multiple patterns, throws an error and exits with a non-zero code when there are no matches (stdout) 1`] = `""`; - -exports[`multiple patterns, throws an error and exits with a non-zero code when there are no matches (write) 1`] = `[]`; +exports[`multiple patterns, throws an error and exits with a non-zero code when there are no matches 1`] = ` +{ + "stderr": "[error] No files matching the given patterns were found.", + "stdout": "", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/print-code.js.snap b/test/__tests__/__snapshots__/print-code.js.snap index c5943c8..521f565 100644 --- a/test/__tests__/__snapshots__/print-code.js.snap +++ b/test/__tests__/__snapshots__/print-code.js.snap @@ -1,5 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Line breaking after filepath with errors (stdout) 1`] = `"foo();"`; +exports[`Line breaking after filepath with errors 1`] = ` +{ + "stdout": "foo();", +} +`; -exports[`Line breaking after filepath with errors (stdout) 2`] = `"foo();"`; +exports[`Line breaking after filepath with errors 2`] = ` +{ + "stdout": "foo();", +} +`; diff --git a/test/__tests__/__snapshots__/skip-folders.js.snap b/test/__tests__/__snapshots__/skip-folders.js.snap index 9ffde85..b386f80 100644 --- a/test/__tests__/__snapshots__/skip-folders.js.snap +++ b/test/__tests__/__snapshots__/skip-folders.js.snap @@ -1,15 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`skip folders passed specifically (stdout) 1`] = ` -"a/file.js -b/file.js" +exports[`skip folders passed specifically 1`] = ` +{ + "stdout": "a/file.js +b/file.js", + "write": [], +} `; -exports[`skip folders passed specifically (write) 1`] = `[]`; - -exports[`skips folders in glob (stdout) 1`] = ` -"a/file.js -b/file.js" +exports[`skips folders in glob 1`] = ` +{ + "stdout": "a/file.js +b/file.js", + "write": [], +} `; - -exports[`skips folders in glob (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/syntax-error.js.snap b/test/__tests__/__snapshots__/syntax-error.js.snap index 48872f7..b3c3302 100644 --- a/test/__tests__/__snapshots__/syntax-error.js.snap +++ b/test/__tests__/__snapshots__/syntax-error.js.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`exits with non-zero code when input has a syntax error (stderr) 1`] = ` -"[error] SyntaxError: Missing semicolon. (1:2) +exports[`exits with non-zero code when input has a syntax error 1`] = ` +{ + "stderr": "[error] SyntaxError: Missing semicolon. (1:2) [error] > 1 | a.2 -[error] | ^" +[error] | ^", + "stdout": "", + "write": [], +} `; - -exports[`exits with non-zero code when input has a syntax error (stdout) 1`] = `""`; - -exports[`exits with non-zero code when input has a syntax error (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/with-node-modules.js.snap b/test/__tests__/__snapshots__/with-node-modules.js.snap index 851de77..ca57eb0 100644 --- a/test/__tests__/__snapshots__/with-node-modules.js.snap +++ b/test/__tests__/__snapshots__/with-node-modules.js.snap @@ -1,41 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`does not ignore node_modules for manual file list (stderr) 1`] = `""`; - -exports[`does not ignore node_modules for manual file list (stdout) 1`] = ` -"nested/node_modules/node-module.js +exports[`does not ignore node_modules for manual file list 1`] = ` +{ + "stderr": "", + "stdout": "nested/node_modules/node-module.js node_modules/node-module.js not_node_modules/file.js -regular-module.js" +regular-module.js", + "write": [], +} `; -exports[`does not ignore node_modules for manual file list (write) 1`] = `[]`; - -exports[`doesn't ignore node_modules with --with-node-modules flag (stderr) 1`] = `""`; - -exports[`doesn't ignore node_modules with --with-node-modules flag (stdout) 1`] = ` -"nested/node_modules/node-module.js +exports[`doesn't ignore node_modules with --with-node-modules flag 1`] = ` +{ + "stderr": "", + "stdout": "nested/node_modules/node-module.js node_modules/node-module.js not_node_modules/file.js -regular-module.js" +regular-module.js", + "write": [], +} `; -exports[`doesn't ignore node_modules with --with-node-modules flag (write) 1`] = `[]`; - -exports[`ignores node_modules by default (stderr) 1`] = `""`; - -exports[`ignores node_modules by default (stdout) 1`] = ` -"not_node_modules/file.js -regular-module.js" +exports[`ignores node_modules by default 1`] = ` +{ + "stderr": "", + "stdout": "not_node_modules/file.js +regular-module.js", + "write": [], +} `; -exports[`ignores node_modules by default (write) 1`] = `[]`; - -exports[`ignores node_modules by with ./**/*.js (stderr) 1`] = `""`; - -exports[`ignores node_modules by with ./**/*.js (stdout) 1`] = ` -"not_node_modules/file.js -regular-module.js" +exports[`ignores node_modules by with ./**/*.js 1`] = ` +{ + "stderr": "", + "stdout": "not_node_modules/file.js +regular-module.js", + "write": [], +} `; - -exports[`ignores node_modules by with ./**/*.js (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/with-parser-inference.js.snap b/test/__tests__/__snapshots__/with-parser-inference.js.snap index 5381c1f..14a07ef 100644 --- a/test/__tests__/__snapshots__/with-parser-inference.js.snap +++ b/test/__tests__/__snapshots__/with-parser-inference.js.snap @@ -1,53 +1,79 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`infers parser from filename (.prettierrc) (stdout) 1`] = `"{}"`; +exports[`infers parser from filename (.prettierrc) 1`] = ` +{ + "stdout": "{}", +} +`; -exports[`infers parser from filename (.stylelintrc YAML) (stdout) 1`] = `"extends: """`; +exports[`infers parser from filename (.stylelintrc YAML) 1`] = ` +{ + "stdout": "extends: """, +} +`; -exports[`infers parser from filename (.stylelintrc) (stdout) 1`] = `"{}"`; +exports[`infers parser from filename (.stylelintrc) 1`] = ` +{ + "stdout": "{}", +} +`; -exports[`infers parser from filename (jakefile) (stdout) 1`] = `"let foo = (x = 1) => x;"`; +exports[`infers parser from filename (jakefile) 1`] = ` +{ + "stdout": "let foo = (x = 1) => x;", +} +`; -exports[`infers parser from filename (lintstagedrc YAML) (stdout) 1`] = ` -""*": - - your-cmd" +exports[`infers parser from filename (lintstagedrc YAML) 1`] = ` +{ + "stdout": ""*": + - your-cmd", +} `; -exports[`infers parser from filename (lintstagedrc) (stdout) 1`] = `"{ "*": "your-cmd" }"`; +exports[`infers parser from filename (lintstagedrc) 1`] = ` +{ + "stdout": "{ "*": "your-cmd" }", +} +`; -exports[`infers parser from filename (swcrc) (stdout) 1`] = ` -"{ +exports[`infers parser from filename (swcrc) 1`] = ` +{ + "stdout": "{ "jsc": { // Requires v1.2.50 or upper and requires target to be es2016 or upper. "keepClassNames": false } -}" +}", +} `; -exports[`infers postcss parser (stderr) 1`] = `""`; - -exports[`infers postcss parser (stdout) 1`] = ` -"/* JavaScript */ +exports[`infers postcss parser 1`] = ` +{ + "stderr": "", + "stdout": "/* JavaScript */ "use strict"; /* Stylesheet */ * { outline: none; -}" +}", + "write": [], +} `; -exports[`infers postcss parser (write) 1`] = `[]`; - -exports[`infers postcss parser with --check (stderr) 1`] = `""`; - -exports[`infers postcss parser with --check (stdout) 1`] = ` -"Checking formatting... -All matched files use Prettier code style!" +exports[`infers postcss parser with --check 1`] = ` +{ + "stderr": "", + "stdout": "Checking formatting... +All matched files use Prettier code style!", + "write": [], +} `; -exports[`infers postcss parser with --check (write) 1`] = `[]`; - -exports[`infers postcss parser with --list-different (stderr) 1`] = `""`; - -exports[`infers postcss parser with --list-different (stdout) 1`] = `""`; - -exports[`infers postcss parser with --list-different (write) 1`] = `[]`; +exports[`infers postcss parser with --list-different 1`] = ` +{ + "stderr": "", + "stdout": "", + "write": [], +} +`; diff --git a/test/__tests__/__snapshots__/with-shebang.js.snap b/test/__tests__/__snapshots__/with-shebang.js.snap index cd5382c..4f57f17 100644 --- a/test/__tests__/__snapshots__/with-shebang.js.snap +++ b/test/__tests__/__snapshots__/with-shebang.js.snap @@ -1,10 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`preserves shebang (stderr) 1`] = `""`; - -exports[`preserves shebang (stdout) 1`] = ` -"#!/usr/bin/env node -"use strict";" +exports[`preserves shebang 1`] = ` +{ + "stderr": "", + "stdout": "#!/usr/bin/env node +"use strict";", + "write": [], +} `; - -exports[`preserves shebang (write) 1`] = `[]`; diff --git a/test/__tests__/__snapshots__/write.js.snap b/test/__tests__/__snapshots__/write.js.snap deleted file mode 100644 index 15a6f0c..0000000 --- a/test/__tests__/__snapshots__/write.js.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`do not write file with --write + formatted file (stderr) 1`] = `""`; - -exports[`do not write file with --write + formatted file (stdout) 1`] = `"formatted.js 0ms (unchanged)"`; - -exports[`do not write file with --write + invalid file (stderr) 1`] = ` -"[error] invalid.js: SyntaxError: Unexpected token (1:17) -[error] > 1 | this is invalid! -[error] | ^" -`; - -exports[`do not write file with --write + invalid file (stdout) 1`] = `""`; - -exports[`write file with --write + unformatted file (stderr) 1`] = `""`; - -exports[`write file with --write + unformatted file (stdout) 1`] = `"unformatted.js 0ms"`; - -exports[`write file with --write + unformatted file (write) 1`] = ` -[ - { - "content": "var x = 1; -", - "filename": "unformatted.js", - }, -] -`; - -exports[`write file with -w + unformatted file (stderr) 1`] = `""`; - -exports[`write file with -w + unformatted file (stdout) 1`] = `"unformatted.js 0ms"`; - -exports[`write file with -w + unformatted file (write) 1`] = ` -[ - { - "content": "var x = 1; -", - "filename": "unformatted.js", - }, -] -`; diff --git a/test/utils.js b/test/utils.js index 10dd8cc..9d81509 100644 --- a/test/utils.js +++ b/test/utils.js @@ -134,24 +134,33 @@ async function runCommand(dir, args, options) { return { cwd, status, stdout, stderr, write }; } -async function runTest(name, expected, getResult, options) { +async function runTest(tests, getResult, options) { const title = options.title || ""; - test(`${title}(${name})`, async () => { + test(title, async () => { let result = await getResult(); - let value = result[name]; - if (expected !== undefined) { - if (name === "status" && expected === "non-zero") { - expect(value).not.toBe(0); - } else if (typeof expected === "function") { - expected(value); - } else { - if (typeof value === "string") { - value = value.replaceAll(result.cwd, "$CWD"); + let snapshot; + for (const name of ["status", "stdout", "stderr", "write"]) { + let value = result[name]; + const expected = tests[name]; + if (expected !== undefined) { + if (name === "status" && expected === "non-zero") { + expect(value).not.toBe(0); + } else if (typeof expected === "function") { + expected(value); + } else { + if (typeof value === "string") { + value = value.replaceAll(result.cwd, "$CWD"); + } + expect(value).toEqual(expected); } - expect(value).toEqual(expected); + } else { + snapshot ??= {}; + snapshot[name] = value; } - } else { - expect(value).toMatchSnapshot(); + } + + if (snapshot) { + expect(snapshot).toMatchSnapshot(); } }); } @@ -173,13 +182,7 @@ function runCli(dir, args = [], options = {}) { get write() { return getResult().then((result) => result.write); }, - test: (tests) => { - for (const name of ["status", "stdout", "stderr", "write"]) { - const expected = tests[name]; - runTest(name, expected, getResult, options); - } - return result; - }, + test: (tests) => runTest(tests, getResult, options), then: (onFulfilled, onRejected) => { return getResult().then(onFulfilled, onRejected); },