components
components copied to clipboard
Testing components
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.
Also, how can we use these to test our work as Component authors?
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 thatApp
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 owntest
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.
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 I think it depends on the use case for each component. Overall, I like the option of writing my own unique test code.
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