Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prettier test compat with Babel 8 #14612

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions scripts/integration-tests/e2e-prettier.sh
Expand Up @@ -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$<in T>() => {}</in>;$<in T>() = {}</in>;$g' tests/format/typescript/optional-variance/{with-jsx.tsx,__snapshots__/jsfmt.spec.js.snap}
node -e '
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 = "`;";
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
Expand Down