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

Add improved assertion library from folio #201

Closed
andrewvc opened this issue Jan 27, 2021 · 5 comments · Fixed by #305
Closed

Add improved assertion library from folio #201

andrewvc opened this issue Jan 27, 2021 · 5 comments · Fixed by #305
Assignees
Labels
discussion Discuss about API changes, enhancements enhancement New feature or request

Comments

@andrewvc
Copy link
Contributor

andrewvc commented Jan 27, 2021

At the moment we're unopinionated about assertions, but, this is something we should probably bake in. One thing to consider would be Microsoft's folio/expect.

We would alias it, so users could import it like import { expect } from '@elastic/synthetics'

As-is, we rely on assert in examples, which is too minimal. While users can use any library, it's good to have one sanctioned one, especially for inline examples (where we should just provide expect.

@vigneshshanmugam @jahtalab @paulb-elastic would love your thoughts here

@andrewvc andrewvc added enhancement New feature or request discussion Discuss about API changes, enhancements labels Jan 27, 2021
@andrewvc andrewvc changed the title Add improved assertion library Add improved assertion library from folio May 24, 2021
@paulb-elastic
Copy link
Contributor

I agree we should make this easier with a more out of the box solution, and this seems a good choice (given the wider Framework’s association with Playwright/runner). As the framework is still only in preview with potential breaking changes, would we want to hold off implementing this into Synthetics GA until it’s ready (users still have the freedom to use assertions like we document today, or add Folio or an alternative)?

@andrewvc
Copy link
Contributor Author

It's important we do something prior to GA that users can depend on. assert is just not great, and I can't see a downside to this approach. We really want 95% of use cases to be able to be accomplished without external libraries IMHO. It will tighten our documentation, and let users focus on writing tests rather than choosing tools.

@hmdhk
Copy link
Contributor

hmdhk commented May 25, 2021

I agree with that the majority of use-case should be supported out of the box without an external lib.
Re. the breaking changes in folio, since we are exposing the methods from our library, we should be able to handle these changes as we keep up with folio releases.

@hmdhk hmdhk self-assigned this May 26, 2021
@vigneshshanmugam
Copy link
Member

Not sure if you are aware, Folio assertion (expect) uses the Jest's expect which is what we should be going for and its released as a standalone package - https://www.npmjs.com/package/expect.

Another cool thing is that we can also add our own matchers by extending the expect.extend - https://jestjs.io/docs/expect#expectextendmatchers and provide functionality like comparing steps screenshots or performance timing events values. Just thinking out load, we don't need it for the first phase.

@andrewvc
Copy link
Contributor Author

andrewvc commented Jun 4, 2021

+1 on just using Jest directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss about API changes, enhancements enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants