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

RFC: Using JSX with k6 #53

Open
behnammodi opened this issue Sep 27, 2024 · 0 comments
Open

RFC: Using JSX with k6 #53

behnammodi opened this issue Sep 27, 2024 · 0 comments

Comments

@behnammodi
Copy link

behnammodi commented Sep 27, 2024

Currently, we are using K6 as our main tool for load testing. We have a large number of React components, each responsible for its own data. I was thinking about how we could leverage the readability of JSX for our load testing. This led me to the idea of using JSX in this context. As a result we can have:

export default () => {
  return JSX.call(
    <HomePage>
      <Header />
      <Banner />
      <Footer />
    </HomePage>
  );
};

and HomePage component looks like:

export const HomePage: FC = ({ children }) => {
  const res = http.get('https://example.com/');

  check(res, {
    'state is 200': r => r.status === 200
  });

  // Will perform <Header />, <Banner /> and <Footer /> if status is 200
  return res.status === 200 ? children : null
};

I created a module that allows JSX to be handled in a non-React environment:

https://github.com/behnammodi/jsx-to-call.

Additionally, I created a template called k6-template-jsx for K6:

https://github.com/behnammodi/k6-template-jsx

Please take a look at this idea and let me know if you have any feedback.

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

No branches or pull requests

1 participant