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

test: Reimplement the Unit Test "requires" #248

Merged
merged 2 commits into from
Apr 10, 2024
Merged

test: Reimplement the Unit Test "requires" #248

merged 2 commits into from
Apr 10, 2024

Conversation

wakamsha
Copy link
Contributor

@wakamsha wakamsha commented Apr 5, 2024

Summary

The existing Unit Test /tests/requires.test.js wasn't working properly, so I reimplemented it.

This test collects the paths of JavaScript files under the specified directory and checks whether they can be loaded correctly (they can be worked require).
However, when I ran the test, I found that it wasn't being collected at all. This was caused by an incorrect implementation of the recursive function, and this was corrected to make it work correctly.

// AS-IS
filePaths: [
  '/eslint-config-moneyforward/configs/test/react.js'
]

// TO-BE
filePaths: [
  '/eslint-config-moneyforward/configs/essentials.js',
  '/eslint-config-moneyforward/configs/jsdoc.js',
  '/eslint-config-moneyforward/configs/next.js',
  '/eslint-config-moneyforward/configs/node.js',
  '/eslint-config-moneyforward/configs/react.js',
  '/eslint-config-moneyforward/configs/storybook.js',
  '/eslint-config-moneyforward/configs/test/react.js',
  '/eslint-config-moneyforward/configs/typescript.js'
]

Other

Introduced eslint-config-prettier to properly format test code with ESLint and Prettier.

References

@wakamsha wakamsha self-assigned this Apr 5, 2024
@wakamsha wakamsha marked this pull request as ready for review April 5, 2024 03:12
Comment on lines +1 to +2
/* eslint-disable import/no-dynamic-require */
/* eslint-disable n/global-require */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test requires dynamic require, so disable the rules for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this file as it's no longer used.
The reimplemented Unit Test revealed that it was unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this file as it's no longer used.
The reimplemented Unit Test revealed that it was unnecessary.

Comment on lines -12 to -14
dirs.forEach((dir) => {
files = readdirRecursively(dir, files);
});
Copy link
Contributor Author

@wakamsha wakamsha Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the processing on L10 is canceled here.

Copy link
Member

@taigakiyokawa taigakiyokawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙆‍♂️

@wakamsha wakamsha merged commit f5f4e9c into main Apr 10, 2024
7 checks passed
@wakamsha wakamsha deleted the implement-tests branch April 10, 2024 03:52
wakamsha added a commit that referenced this pull request Apr 18, 2024
* implement `requires` test

* lint test files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants