Due to complications with automating certain parts of our workflow strictly through the front-end, we need to make an HTTP request before our front-end automation tests run in order to setup test data.
Using the TestCafe docs I tried piecing something together, and while the test runs, the http request is not getting executed. Here's the code I have:
import {Selector, ClientFunction, RequestHook} from 'testcafe';
class CreateTestMove extends RequestHook {
async onRequest (event) {
event.requestOptions.method = "POST";
event.requestOptions.url = "https://api.com/move/sample";
event.requestOptions.body["companyKey"] = "xxxxxxxxx";
event.requestOptions.headers["X-Company-Secret"] = "xxxxxxxxx";
event.requestOptions.headers["X-Permanent-Access-Token"] = "xxxxxxxx"
}
}
const customHook = new CreateTestMove();
fixture `Call Create Test Move`
.before(async ctx => {
customHook;
})
I'm not super familiar with JS, so probably did something obviously wrong here, just not sure what it is.
Aucun commentaire:
Enregistrer un commentaire