My frontend depends of a json configuration file that holds various parameters that can modify the content of the page.
When the test starts, my file has a specific content. I would like to find a way to write this file but only for the current test so no state is left for the next test.
This is my current solution, but problem is that if tests fail, the original version of the file is not reset. What could be another approach ?
it('should work a specific way with the given configuration', () => {
cy.readFile('my-app/parameters.json').then(
(originalFile) => {
// Modify the json file however I'd like
cy.writeFile('my-app/parameters.json', someConfiguration);
// Test details
cy.writeFile('my-app/parameters.json', originalFile);
}
);
});