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

Add test for changing name of _typeof helper (for @babel/plugin-transform-typeof-symbol) #11743

Closed

Conversation

yukihirop
Copy link

@yukihirop yukihirop commented Jun 24, 2020

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Summary

The name of the helper changes from _typeof to _typeof2 .

  • When the function name in the function declaration is is _typeof
  • When the variable name of the function expression is _typeof
  • When the function name of the function expression is _typeof

So I add tests about it.

Bebel REPL ↓↓

image

Test

#~/JavaScriptProjects/babel (add_test_about-transform-typeof-symbol)
$ TEST_ONLY=babel-plugin-transform-typeof-symbol make test
BABEL_ENV=test yarn --silent eslint scripts packages codemods eslint '*.js' --format=codeframe
scripts/lint-ts-typings.sh
BABEL_ENV=test ./scripts/test.sh
 PASS  packages/babel-plugin-transform-typeof-symbol/test/helper.spec.js
 PASS  packages/babel-plugin-transform-typeof-symbol/test/index.js

Test Suites: 2 passed, 2 total
Tests:       14 passed, 14 total
Snapshots:   0 total
Time:        4.024s
Ran all test suites matching /(packages|codemods|eslint)\/.*babel-plugin-transform-typeof-symbol.*\/test/i.
/Applications/Xcode.app/Contents/Developer/usr/bin/make test-clean
rm -rf  packages/*/test/tmp
rm -rf  packages/*/test-fixtures.json
rm -rf  codemods/*/test/tmp
rm -rf  codemods/*/test-fixtures.json
rm -rf  eslint/*/test/tmp
rm -rf  eslint/*/test-fixtures.json

The name of the helper changes from _typeof to _typeof2.

* When the function name in the function declaration is is _typeof
* When the variable name of the function expression is _typeof
* When the function name of the function expression is _typeof
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/24489/

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0565c09:

Sandbox Source
serene-galileo-m9g4l Configuration
cranky-keller-bvt9p Configuration

@JLHwung
Copy link
Contributor

JLHwung commented Jun 30, 2020

The behaviour is rooted from generateUid:

uid = this._generateUid(name, i);
i++;

and tested in

test("generateUid collision check after re-crawling", function () {

I don't think we have specificial-cased _typeof in our codebase so I am afraid test on _typeof here is not of much value.

@JLHwung JLHwung closed this Jun 30, 2020
@yukihirop
Copy link
Author

@JLHwung

Thank you for review 🙇‍♂️

I learned a lot.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 30, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants