From 18ed55a771c8088abfd797a40ca8018ea76e226a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 28 May 2022 16:15:34 +0200 Subject: [PATCH 1/3] Fix prettier test compat with Babel 8 --- scripts/integration-tests/e2e-prettier.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/integration-tests/e2e-prettier.sh b/scripts/integration-tests/e2e-prettier.sh index 6d90b1fd86ab..d726a94ef163 100755 --- a/scripts/integration-tests/e2e-prettier.sh +++ b/scripts/integration-tests/e2e-prettier.sh @@ -38,6 +38,24 @@ export YARN_IGNORE_PATH=1 startLocalRegistry "$root"/verdaccio-config.yml yarn install +if [ "$BABEL_8_BREAKING" = true ] ; then + # Prettier's tests use `>` in JSX, which is invalid syntax + sed -i 's§() => {}() = {};§g' tests/format/typescript/optional-variance/{with-jsx.tsx,__snapshots__/jsfmt.spec.js.snap} + node -e ' + const filepath = "jsfmt.spec.js.snap"; + const file = fs.readFileSync(filepath, "utf8"); + const BEFORE_READ = "exports[`with-jsx.tsx [babel-ts] format 1`] = `"; + const END_READ = "`;"; + const BEFORE_WRITE = "exports[`with-jsx.tsx [typescript] format 1`] = `"; + const read_start = file.indexOf(BEFORE_READ) + BEFORE_READ.length; + const read_end = file.indexOf(END_READ, read_start) + END_READ.length; + const write_start = file.indexOf(BEFORE_WRITE) + BEFORE_WRITE.length; + + const newFile = file.slice(0, write_start) + file.slice(read_start, read_end); + fs.writeFileSync(filepath, newFile); + ' +fi + # Only run js,jsx,misc format tests # Without --runInBand CircleCI hangs. yarn test "tests/format/(jsx?|misc)/" --update-snapshot --runInBand From 7b4a36b35c44e6072bfb26eb4ffa69bf9db75cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 28 May 2022 17:32:52 +0200 Subject: [PATCH 2/3] Update scripts/integration-tests/e2e-prettier.sh --- scripts/integration-tests/e2e-prettier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/integration-tests/e2e-prettier.sh b/scripts/integration-tests/e2e-prettier.sh index d726a94ef163..068a74360dda 100755 --- a/scripts/integration-tests/e2e-prettier.sh +++ b/scripts/integration-tests/e2e-prettier.sh @@ -40,7 +40,7 @@ yarn install if [ "$BABEL_8_BREAKING" = true ] ; then # Prettier's tests use `>` in JSX, which is invalid syntax - sed -i 's§() => {}() = {};§g' tests/format/typescript/optional-variance/{with-jsx.tsx,__snapshots__/jsfmt.spec.js.snap} + sed -i 's$() => {};$() = {};$g' tests/format/typescript/optional-variance/{with-jsx.tsx,__snapshots__/jsfmt.spec.js.snap} node -e ' const filepath = "jsfmt.spec.js.snap"; const file = fs.readFileSync(filepath, "utf8"); From e0888c1629e36c1c9725a543a12ebc201ae29248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 28 May 2022 18:59:46 +0200 Subject: [PATCH 3/3] Update scripts/integration-tests/e2e-prettier.sh --- scripts/integration-tests/e2e-prettier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/integration-tests/e2e-prettier.sh b/scripts/integration-tests/e2e-prettier.sh index 068a74360dda..181013edb0df 100755 --- a/scripts/integration-tests/e2e-prettier.sh +++ b/scripts/integration-tests/e2e-prettier.sh @@ -42,7 +42,7 @@ if [ "$BABEL_8_BREAKING" = true ] ; then # Prettier's tests use `>` in JSX, which is invalid syntax sed -i 's$() => {};$() = {};$g' tests/format/typescript/optional-variance/{with-jsx.tsx,__snapshots__/jsfmt.spec.js.snap} node -e ' - const filepath = "jsfmt.spec.js.snap"; + const filepath = "tests/format/typescript/optional-variance/__snapshots__/jsfmt.spec.js.snap"; const file = fs.readFileSync(filepath, "utf8"); const BEFORE_READ = "exports[`with-jsx.tsx [babel-ts] format 1`] = `"; const END_READ = "`;";