components icon indicating copy to clipboard operation
components copied to clipboard

Testing components

Open austencollins opened this issue 6 years ago • 5 comments

We know the use-case of each Component, how can we use this knowledge to help users test their work? Just as you shouldn't have to figure out how to build a RestAPI (you just use its component), you shouldn't have to figure out how to test it. It should just come with the Component.

austencollins avatar Feb 20 '19 14:02 austencollins

Also, how can we use these to test our work as Component authors?

austencollins avatar Feb 20 '19 17:02 austencollins

hmmm maybe each component would have its own test method?

Here's how I'd personally use Serverless Components:

  • I'd create a serverless.js file
  • create a class representing my App
  • load any component I want via this.load as a child component.
  • add my own test method in that App component that does whatever I want! This method would always be changing depending on what I want to test. It would be helpful if child components has their own test methods.

This looks a lot like React with this parent App component. This is related to #10, and because of the above, I was leaning towards keeping things simple and only support programatic usage according to the above pattern. But this is honestly subjective.

eahefnawy avatar Feb 21 '19 10:02 eahefnawy

The question here is what test means. Does it mean that I can do a simple test function invocation? Will it run the components unit tests via npm test or will it run an integration tests where it deploys the component (spins up a separate environment) and then auto-generates API tests which it then exercises?

Looks like it depends on the abstraction the component provides. The higher the abstraction, the more the test function needs to do.

It would be great if we could establish a pattern here so that test is a predictable command.

pmuens avatar Feb 21 '19 10:02 pmuens

@pmuens I think it depends on the use case for each component. Overall, I like the option of writing my own unique test code.

eahefnawy avatar Feb 21 '19 13:02 eahefnawy

The question here is what test means.

+1

Looks like it depends on the abstraction the component provides.

I think it depends on the use case for each component.

+1

It would be great if we could establish a pattern here so that test is a predictable command.

+1

austencollins avatar Feb 22 '19 02:02 austencollins