From 16cd64d11a7ce316c2df83fb49a3bceae6dce6e5 Mon Sep 17 00:00:00 2001 From: Louis Chan Date: Mon, 12 Dec 2022 12:53:18 +0800 Subject: [PATCH] Make snapshot stable --- src/__snapshots__/index.test.js.snap | 20 ++++++++++---------- src/index.test.js | 9 ++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/__snapshots__/index.test.js.snap b/src/__snapshots__/index.test.js.snap index 35824b5..3a42747 100644 --- a/src/__snapshots__/index.test.js.snap +++ b/src/__snapshots__/index.test.js.snap @@ -1,21 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`does not warn any other flex-* 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":false,"warnings":[]}]"`; +exports[`does not warn any other flex-* 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":false,"warnings":[]}]"`; -exports[`handles spaces 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"Expected 3-values form of flex: ; (oursky/flex)"}]}]"`; +exports[`handles spaces 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":19,"rule":"oursky/flex","severity":"error","text":"Expected 3-values form of flex: ; (oursky/flex)"}]}]"`; -exports[`passes well-formed flex 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":false,"warnings":[]}]"`; +exports[`passes well-formed flex 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":false,"warnings":[]}]"`; -exports[`warns 1-value forms 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"Expected 3-values form of flex: ; (oursky/flex)"}]}]"`; +exports[`warns 1-value forms 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":11,"rule":"oursky/flex","severity":"error","text":"Expected 3-values form of flex: ; (oursky/flex)"}]}]"`; -exports[`warns 2-value forms 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"Expected 3-values form of flex: ; (oursky/flex)"}]}]"`; +exports[`warns 2-value forms 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":13,"rule":"oursky/flex","severity":"error","text":"Expected 3-values form of flex: ; (oursky/flex)"}]}]"`; -exports[`warns flex-basis 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"flex-[grow|shrink|basis] are not supported on IE 10. Use flex. (oursky/flex)"}]}]"`; +exports[`warns flex-basis 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":17,"rule":"oursky/flex","severity":"error","text":"flex-[grow|shrink|basis] are not supported on IE 10. Use flex. (oursky/flex)"}]}]"`; -exports[`warns flex-grow 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"flex-[grow|shrink|basis] are not supported on IE 10. Use flex. (oursky/flex)"}]}]"`; +exports[`warns flex-grow 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":16,"rule":"oursky/flex","severity":"error","text":"flex-[grow|shrink|basis] are not supported on IE 10. Use flex. (oursky/flex)"}]}]"`; -exports[`warns flex-shrink 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"flex-[grow|shrink|basis] are not supported on IE 10. Use flex. (oursky/flex)"}]}]"`; +exports[`warns flex-shrink 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":18,"rule":"oursky/flex","severity":"error","text":"flex-[grow|shrink|basis] are not supported on IE 10. Use flex. (oursky/flex)"}]}]"`; -exports[`warns unitless flex-basis 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"flex-basis: 0 not allowed. Please include unit. (oursky/flex)"}]}]"`; +exports[`warns unitless flex-basis 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":20,"rule":"oursky/flex","severity":"error","text":"flex-basis: 0 not allowed. Please include unit. (oursky/flex)"}]}]"`; -exports[`warns unitless flex-basis of any number 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"rule":"oursky/flex","severity":"error","text":"flex-basis: 1 not allowed. Please include unit. (oursky/flex)"}]}]"`; +exports[`warns unitless flex-basis of any number 1`] = `"[{"source":"","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":1,"column":3,"endLine":1,"endColumn":20,"rule":"oursky/flex","severity":"error","text":"flex-basis: 1 not allowed. Please include unit. (oursky/flex)"}]}]"`; diff --git a/src/index.test.js b/src/index.test.js index 80b38e6..451038b 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -14,7 +14,14 @@ function lint(code) { }, }) .then((result) => { - return result.output; + // The source property is random. + // So we want to remove it to make the snapshot stable. + const outputString = result.output; + const output = JSON.parse(outputString); + for (const a of output) { + a.source = ""; + } + return JSON.stringify(output); }); }