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

[Gru Tester] Add unit test for src/babel/plugin-react-refresh.ts #7

Open
wants to merge 1 commit into
base: gru-unit-test
Choose a base branch
from

Conversation

gru-bot
Copy link

@gru-bot gru-bot commented Sep 26, 2024

Score (skipped)

0

Source Code

Link

Value & Challenge

Field Level
topValue Critical
bottomValue Critical
topChallenge Challenging
bottomChallenge Challenging
Value Detail
reactRefreshPlugin:
  value: Critical
  reason: This function is a Babel plugin responsible for transforming and caching atoms, which is core functionality. Errors could lead to incorrect code transformation, potentially causing data loss or system crashes. It involves important logic with high dependency on its correctness, making it highly worth unit testing.
Challenge Detail
reactRefreshPlugin:
  challenge: Challenging
  reason: The function involves complex logic with multiple conditional branches and uses Babel's AST transformations. It interacts with external modules like Babel and requires mocking for testing. The code also handles nested data structures and involves intricate processing, making it challenging to test.

Coverage

The change in coverage value, such as: 0% -> 50%, indicates that the coverage was 0% before writing the tests and 50% after writing them.

https://web.dev/articles/ta-code-coverage

Type Change
lines
statements
branches
functions

Langsmith Link

Link

Step writeAndRunTest Overview

Index Pre Passed Test Passed Post Passed
1
2
3
4
5
6
7
8

Last Model Result

Pre

Exec

npx vitest run /jotai/src/babel/plugin-react-refresh.gru.test.ts (0)
�[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.�[39m

 RUN  v2.1.1 /jotai

 ✓ |jotai| src/babel/plugin-react-refresh.gru.test.ts  (4 tests) 503ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  13:00:07
   Duration  2.58s (transform 150ms, setup 0ms, collect 355ms, tests 503ms, environment 541ms, prepare 206ms)

Post

pnpm test:format (0)
> jotai@2.10.0 test:format /jotai
> prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --list-different

pnpm test:types (0)
> jotai@2.10.0 test:types /jotai
> tsc --noEmit

pnpm test:lint (0)
> jotai@2.10.0 test:lint /jotai
> eslint --no-eslintrc --c .eslintrc.json '*.{js,ts}' '{src,tests,benchmarks}/**/*.{ts,tsx}'

@vangie
Copy link

vangie commented Sep 27, 2024

这个测试两个问题

  1. 这个代码是有测试,agent 没有发现,https://github.com/babelcloud/jotai/blob/609fe758f2b62badf495cac508f3ae0b1188c4d9/tests/babel/plugin-react-refresh.test.ts
  2. 构造的示例和断言都不如原来的测试好,特别是断言,只断言了 contains 的情况,不足以说明其结果正确。

@vangie vangie added the invalid This doesn't seem right label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants