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

Jest testing framework #997 #2195

Merged
merged 2 commits into from
Apr 10, 2023
Merged

Jest testing framework #997 #2195

merged 2 commits into from
Apr 10, 2023

Conversation

andretchen0
Copy link
Contributor

@andretchen0 andretchen0 commented Apr 8, 2023

This adds the Jest testing framework to the project.

Adding tests

Copying the style of the React repository, tests can be added into /src/__tests__/*.js.

Note

There was discussion of putting Jest tests into a folder named __jest__ as a precaution against conflicts with a future testing framework. This PR does not do that. It follows Jest's defaults.

Reasoning: If an additional, testing framework is added in the future and there is a naming conflict, __tests__ can be renamed and the jest.config.js testMatch field can be updated to match. In the meantime, there's no reason to change the defaults.

Writing tests

Tests can be written following the examples from the Jest documentation.

However, Ancient Beast's already-installed linter as well as the checks run on Github require that the Jest module values be imported explicitly, e.g.,

import { expect, describe, test } from '@jest/globals';

See /src/__tests__/utility/string.js for an example.

Running tests

The test runner was added to the existing npm run test.

In addition, the following commands were added to package.json:

  • npm run jest – Run tests
  • npm run start:jest – Watch test files and rerun when modified

@vercel
Copy link

vercel bot commented Apr 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ancientbeast ✅ Ready (Inspect) Visit Preview Apr 8, 2023 1:22pm

@ghost
Copy link

ghost commented Apr 8, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@andretchen0 andretchen0 marked this pull request as ready for review April 8, 2023 13:43
@DreadKnight DreadKnight merged commit c802d8c into FreezingMoon:master Apr 10, 2023
@DreadKnight DreadKnight added coding This issue requires some programming pipeline Affects how the project is being developed priority This should get fixed as soon as possible! labels Apr 10, 2023
@DreadKnight DreadKnight added this to the 0.5 - Chimera milestone Apr 10, 2023
@DreadKnight
Copy link
Member

DreadKnight commented Apr 10, 2023

@andretchen0 Well done! Merged this in. Some of that info from original post should be included either in our Contribution guide or in a wiki page (linked in from the guide as well perhaps).

@DreadKnight
Copy link
Member

Added section in the Contribution guide about it bec7e55

@andretchen0 andretchen0 deleted the jest-merge branch April 10, 2023 12:28
CyberBishop pushed a commit to CyberBishop/AncientBeast that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coding This issue requires some programming pipeline Affects how the project is being developed priority This should get fixed as soon as possible!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants