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

feat: Integrate Jest for JavaScript testing with CI setup #28

Merged
merged 8 commits into from
Nov 26, 2024

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Nov 20, 2024

Resolves #27

Set up a modern JavaScript testing framework using Jest, integrated with the existing webpack build system. Configure Babel for modern JavaScript support and establish a test file structure and conventions. Update the package.json to include Jest dependencies and scripts for running tests, watching tests, and generating coverage reports. Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

New Features:

  • Introduce a modern JavaScript testing framework using Jest, integrated with the existing webpack build system.

Enhancements:

  • Configure Babel for modern JavaScript support with a new Babel configuration file.

CI:

  • Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

Tests:

  • Establish a test file structure and conventions for JavaScript tests, including an example test file to verify the setup.
  • Configure test coverage reporting for JavaScript code.

This PR was automatically generated.

If you want to make changes to this PR:

  • Leave a review and I'll make the changes
  • Leave a comment with the changes you want to see
  • Push commits to the branch

Summary by Sourcery

Integrate Jest for JavaScript testing, configure Babel for modern JavaScript support, and establish a CI pipeline to run JavaScript tests alongside existing Python tests. Update package.json to include Jest dependencies and scripts for running tests, watching tests, and generating coverage reports.

New Features:

  • Introduce Jest as a modern JavaScript testing framework integrated with the existing webpack build system.

Enhancements:

  • Configure Babel for modern JavaScript support with a new Babel configuration file.

CI:

  • Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

Tests:

  • Establish a test file structure and conventions for JavaScript tests, including an example test file to verify the setup.
  • Configure test coverage reporting for JavaScript code.

Set up a modern JavaScript testing framework using Jest, integrated with the existing webpack build system. Configure Babel for modern JavaScript support and establish a test file structure and conventions. Update the package.json to include Jest dependencies and scripts for running tests, watching tests, and generating coverage reports. Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

New Features:
- Introduce a modern JavaScript testing framework using Jest, integrated with the existing webpack build system.

Enhancements:
- Configure Babel for modern JavaScript support with a new Babel configuration file.

CI:
- Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

Tests:
- Establish a test file structure and conventions for JavaScript tests, including an example test file to verify the setup.
- Configure test coverage reporting for JavaScript code.

Resolves #27
@sourcery-ai sourcery-ai bot requested a review from fsbraun November 20, 2024 14:22
Copy link
Member

@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

Please add a github action that run the javascript tests

@fsbraun
Copy link
Member

fsbraun commented Nov 22, 2024

@sourcery-ai update

Copy link
Contributor Author

sourcery-ai bot commented Nov 22, 2024

I'm sorry, I don't understand the command @sourcery-ai update.

Please use @sourcery-ai review to request a review.

@fsbraun
Copy link
Member

fsbraun commented Nov 22, 2024

@sourcery-ai review

Copy link
Contributor Author

sourcery-ai bot commented Nov 22, 2024

Reviewer's Guide by Sourcery

This PR implements a JavaScript testing infrastructure using Jest, integrated with the existing webpack build system. The implementation includes Jest configuration, Babel setup for modern JavaScript support, test file structure setup, and CI integration. The changes primarily involve adding necessary dependencies, configuring Jest and Babel, and setting up test utilities and example tests.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Configure Jest testing framework with necessary dependencies
  • Add Jest and related testing libraries as dev dependencies
  • Add test-related npm scripts for running tests, watch mode, and coverage
  • Configure Jest environment to use jsdom for DOM testing
package.json
jest.config.js
Set up Babel configuration for modern JavaScript support
  • Configure Babel preset-env for current Node.js environment
  • Set up Babel integration with Jest
babel.config.js
Establish test file structure and utilities
  • Create mock handlers for static assets (files and styles)
  • Set up test environment configuration file
  • Add example test file demonstrating basic and DOM testing capabilities
tests/js/__mocks__/fileMock.js
tests/js/__mocks__/styleMock.js
tests/js/setup-tests.js
tests/js/example.test.js

Assessment against linked issues

Issue Objective Addressed Explanation
#27 Set up a modern and widely-used JavaScript testing framework

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @sourcery-ai[bot] - I've reviewed your changes - here's some feedback:

Overall Comments:

  • There are duplicate devDependencies in package.json for @babel/core, @babel/preset-env, @testing-library/dom, @testing-library/jest-dom, babel-jest, jest, and jest-environment-jsdom. Please remove the duplicated entries.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +45 to +52
"webpack-cli": "^5.1.4",
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^6.4.2",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

issue (bug_risk): Remove duplicate dev dependencies

Several dependencies (@babel/core, @babel/preset-env, @testing-library/dom, @testing-library/jest-dom, babel-jest, jest, jest-environment-jsdom) are listed twice with different versions. This could cause confusion and potential version conflicts. Please remove the duplicate entries and keep only one version of each dependency.

@fsbraun fsbraun merged commit 2a3ba24 into main Nov 26, 2024
22 checks passed
@fsbraun fsbraun deleted the sourcery-ai/issue-27 branch November 26, 2024 14:20
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.

chore: No testing framework for javascript present
1 participant