You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firstly, thanks for creating this excellent library. This helps me a lot!
Currently, Miragejs works excellently when it comes to testing React components that interact with external APIs.
My setup follows the doc about Factories.
(1) Start Mirage server
(2) Create test data
(3) Render the target component, set some expectations
(4) Shutdown Mirage server
But sometimes, I also need to test stateless components by passing data directly as props. In those cases, I think it could be great if I could use Factories to create test data without steps (1) and (4).
Currently, I can do this:
const Factory = MyFactory.extend(mergedExtensions); // (1)
let factory = new Factory(); // (2)
return factory.build(sequence); // (3) -> sequence is managed by the test case
But there are some small issues:
Typescript issues:
new Factory() -> There is no constructor
factory.build(sequence) -> There is no build function exported
Code boilerplate. Ideally, I think we should be able to do this:
MyFactory.extend(mergedExtensions).build()
To achieve this, I think we can add build to the Factory type, and use/store sequence internally if the external sequence is not provided.
I am happy to create an MR for this suggestion if you don't mind!
The text was updated successfully, but these errors were encountered:
Firstly, thanks for creating this excellent library. This helps me a lot!
Currently, Miragejs works excellently when it comes to testing React components that interact with external APIs.
My setup follows the doc about Factories.
But sometimes, I also need to test stateless components by passing data directly as props. In those cases, I think it could be great if I could use Factories to create test data without steps (1) and (4).
Currently, I can do this:
But there are some small issues:
new Factory()
-> There is no constructorfactory.build(sequence)
-> There is nobuild
function exportedMyFactory.extend(mergedExtensions).build()
build
to the Factory type, and use/storesequence
internally if the externalsequence
is not provided.I am happy to create an MR for this suggestion if you don't mind!
The text was updated successfully, but these errors were encountered: