Skip to content

test: test infra #2085

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

Merged
merged 21 commits into from
May 5, 2024
Merged

test: test infra #2085

merged 21 commits into from
May 5, 2024

Conversation

talkor
Copy link
Member

@talkor talkor commented Apr 21, 2024

  • Import jest-dom globally and remove unnecessary imports of jest-dom
  • Add test watch mode
  • Add setupTests file and rename old config

https://monday.monday.com/boards/3532714909/pulses/5657864174
https://monday.monday.com/boards/3532714909/pulses/6426652552

@talkor talkor requested a review from a team as a code owner April 21, 2024 16:33
Copy link
Contributor

@YossiSaadi YossiSaadi left a comment

Choose a reason for hiding this comment

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

Awesome work! I had some comments

// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
setupFilesAfterEnv: ["<rootDir>/setupTests.js"],
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure it should be running for every test? can it run globally in the global setup?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see you can also do:

testEnvironment: 'jest-environment-jsdom',

https://testing-library.com/docs/react-testing-library/setup/#jest-27

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of having this file

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like setupTest is still needed, but changed to jest-environment-jsdom anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is a bit outdated, I'll open a task to revisit it

"ts-loader": "^9.3.1",
"ts-node": "^10.9.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it needed?

Copy link
Member Author

@talkor talkor May 5, 2024

Choose a reason for hiding this comment

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

To use TS config with Jest, (i.e. in node)

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe upgrade the version here to be exactly like core, so it would be a shared dep between the two packages, just for convenience

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about it, I'll check

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -2,6 +2,8 @@ const path = require("path");

module.exports = {
process(src, filename) {
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
return {
Copy link
Member Author

Choose a reason for hiding this comment

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

Due to Jest breaking chnages

Copy link
Contributor

Choose a reason for hiding this comment

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

do we even need the override here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Lemme check, probably not

Copy link
Contributor

Choose a reason for hiding this comment

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

same - do we even need the override here?

@@ -340,7 +340,7 @@ export const TransitionAnimation = {
]);

setNumActions(numActions + 1);
}, [steps, setSteps, numActions, setNumActions]);
}, [numActions, steps, getStepKeyForTransition, STEP_TRANSITIONS, clearSteps]);
Copy link
Member Author

Choose a reason for hiding this comment

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

It was missing

@@ -95,8 +95,7 @@ describe("useDebounceEvent", () => {
const additionalDelay = 200;

beforeEach(() => {
// @ts-ignore
jest.useFakeTimers("modern");
jest.useFakeTimers();
Copy link
Member Author

Choose a reason for hiding this comment

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

API changed, this is the same

@@ -39,8 +39,7 @@
"lint:fix": "eslint \"./src/**/*.{js,jsx,ts,tsx}\" --fix",
"prettier:fix": "prettier --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
"test": "jest --passWithNoTests",
"test:update": "yarn test -- -u",
"test:stories": "testing=storybook TEST_END_FILES=jest-story jest --passWithNoTests",
"test:update": "yarn test -u",
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the -- due to yarn warning that it's not needed

@@ -59,7 +59,7 @@ const commonExtends = ["plugin:react/recommended", "plugin:react-hooks/recommend
module.exports = {
overrides: [
{
files: ["*.jest.js", "jest.setup.js", "jest.init.js"],
files: ["jest.init.js"],
Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out it's needed for eslint, keeping it for now

@talkor talkor requested a review from YossiSaadi May 5, 2024 12:48
Copy link
Contributor

@YossiSaadi YossiSaadi left a comment

Choose a reason for hiding this comment

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

Awesome work! we really needed this one!!

@talkor talkor merged commit 4425821 into master May 5, 2024
@talkor talkor deleted the talko/test/test-infra branch May 5, 2024 12:54
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