Skip to content

Conversation

@claneo
Copy link
Contributor

@claneo claneo commented Dec 6, 2025

Summary

  1. Collect test location via error stack
  2. list command
    1. Added new option --printLocation
    2. List test suites too
  3. Added new reporter hook onTestFileReady, this will be used in vscode extension later

The location maybe inaccurate because rspack transpiled describe() call to (0,rstest_core.describe)(), so the location got from error stack is the end of the comma expression. Chained method is not affected expect describe.for which is tranpiled to describe["for"].

$ cd e2e && npx rstest list ./build --printLocation
build/index.test.ts:9:9 > test build config
build/index.test.ts:10:20 > test build config > define config should work correctly
build/index.test.ts:10:20 > test build config > alias config should work correctly
build/index.test.ts:10:20 > test build config > plugin config should work correctly
build/index.test.ts:10:20 > test build config > tools/rspack config should work correctly
build/index.test.ts:10:20 > test build config > decorators config should work correctly
build/resolve.test.ts:9:3 > should resolve correctly 
build/runtimeImport/index.test.ts:8:3 > should load runtime deps correctly
build/runtimeImport/index.test.ts:13:3 > should load compile-time deps correctly

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Dec 6, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 9dc14b2
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/6938daa880955300086a5473
😎 Deploy Preview https://deploy-preview-739--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@claneo claneo marked this pull request as ready for review December 7, 2025 05:56
Copilot AI review requested due to automatic review settings December 7, 2025 05:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds test location tracking functionality to rstest by collecting source locations via error stack traces, enabling the list command to display location information and adding a new reporter hook for test file readiness.

  • Introduces Location type and integrates location tracking throughout test collection pipeline
  • Adds --printLocation CLI flag to list command and includes test suites in list output
  • Adds onTestFileReady reporter hook that fires after test collection but before execution

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/core/src/types/worker.ts Adds onTestFileReady RPC method for worker-to-server communication
packages/core/src/types/testSuite.ts Defines Location type and adds location fields to test types; introduces TestInfo and TestSuiteInfo types
packages/core/src/types/runner.ts Adds onTestFileReady hook to RunnerHooks interface
packages/core/src/types/reporter.ts Adds onTestFileReady hook to Reporter interface
packages/core/src/types/core.ts Adds printLocation option to ListCommandOptions and changes return type to ListCommandResult[]
packages/core/src/runtime/worker/index.ts Invokes onTestFileReady RPC after test collection
packages/core/src/runtime/runner/runtime.ts Implements getLocation() function using stacktrace-parser and integrates location capture into test/describe APIs
packages/core/src/runtime/runner/runner.ts Adds type: 'case' to TestCaseInfo construction
packages/core/src/runtime/runner/index.ts Maps Test objects to TestInfo and invokes onTestFileReady hook
packages/core/src/pool/index.ts Propagates onTestFileReady calls to all reporters
packages/core/src/core/listTests.ts Implements location printing and includes test suites in output
packages/core/src/core/index.ts Updates listTests return type
packages/core/src/cli/commands.ts Adds --printLocation CLI option
e2e/rstest.config.ts Changes test timeout from conditional to fixed 10s
e2e/reporter/rstest.customReporterConfig.ts Implements onTestFileReady in test reporter
e2e/reporter/index.test.ts Adds assertion for onTestFileReady hook invocation
e2e/list/json.test.ts Updates test expectations to include suites and locations
e2e/list/index.test.ts Updates test expectations and adds location printing test
e2e/list/fixtures/c.test.ts Adds test fixture covering various describe/it API patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant