What would be the proper/recommended way to add an external library like faker.js to Siesta?
https://github.com/Marak/faker.js
Support Forum
Make it a property of the test class. So you'll need to load the library on the harness page, assign "faker" as a property of the test class (lets say in "initialize" method, don't forget to call SUPER). And then you can do: "t.faker.something()"
Read the API documentation
Ok thanks! I thought that'd be what I'd want to do.
Just for clarification though, when you say on the harness page, you do mean index.html (the same place I'd load Siesta's library)?
This is what I've done and faker is available from the test object but it's also in the global scope of the browser window (available as both faker and test.faker, during test execution).
Just for clarification though, when you say on the harness page, you do mean index.html (the same place I'd load Siesta's library)?
This is what I've done and faker is available from the test object but it's also in the global scope of the browser window (available as both faker and test.faker, during test execution).
Yes, under harness page I mean "index.html"
This means you include it in the preload? Or it is included in your application bundle? If it is loaded only on the harness page, it should be in the global scope of the test page.This is what I've done and faker is available from the test object but it's also in the global scope of the browser window (available as both faker and test.faker, during test execution).
Read the API documentation
Shouldn't be like that, then probably faker is loaded by your app somehow (bundled with webpack or something?). In the breakpoint inside the test you can verify it with "window.faker === window.parent.faker" - should be false - different copies of faker.
Read the API documentation