Skip to content

Conversation

andrewslotin
Copy link
Contributor

What?

Update script templates used by k6 new to use the new expect() syntax introduced in k6-jslib-testing

Why?

k6-jslib-testing aims to replace the old check() API with a flexible and user-friendly set o matchers. This PR updates the templates used by k6 new to use this API.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.
  • I have added the correct milestone and labels to the PR.

@andrewslotin andrewslotin added this to the v1.3.0 milestone Aug 11, 2025
@andrewslotin andrewslotin requested a review from a team as a code owner August 11, 2025 14:22
Copy link
Contributor

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

I personally prefer the new asserts library, but i think check still has a place, especially in load testing and when working with thresholds. Does it make sense to have a check example in the template with a comment as to why we might want that or is that not needed for this particular template?

@andrewslotin andrewslotin modified the milestones: v1.3.0, v1.2.0 Aug 11, 2025
@andrewslotin
Copy link
Contributor Author

@ankur22, the plan is to move away from check() in long-term. In future k6-testing will become the go-to API to assert on values and needs to have feature parity with check(). I'm wondering what are the use-cases that currently cannot be covered by expect()?

Copy link
Contributor

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

🚀

@oleiade
Copy link
Contributor

oleiade commented Aug 11, 2025

@andrewslotin We have, at this point, explicitly excluded emitting assertion-related metrics, by design, because it wasn't part of the initial intent. That's the main difference. We could eventually address that difference, but I'm not entirely sure how much work would be needed.

@andrewslotin andrewslotin merged commit 506791b into master Aug 11, 2025
37 checks passed
@andrewslotin andrewslotin deleted the use_testing_in_templates branch August 11, 2025 15:13
ankur22 pushed a commit to HasithDeAlwis/k6 that referenced this pull request Aug 13, 2025
paulnegz pushed a commit to paulnegz/k6 that referenced this pull request Sep 2, 2025
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.

3 participants