2023-02-20 18:17:38 +00:00
|
|
|
/* eslint-env mocha */
|
|
|
|
/* global cy */
|
2024-01-29 18:08:06 +00:00
|
|
|
describe("datashard/snapshot", () => {
|
|
|
|
context("simple types"
|
2024-01-31 08:22:07 +00:00
|
|
|
// , { env: { updateSnapshots: true } }
|
2024-01-29 18:08:06 +00:00
|
|
|
, () => {
|
|
|
|
it("works with objects", () => {
|
|
|
|
cy.wrap({
|
|
|
|
"foo": "bar",
|
|
|
|
"Fizzy Drink": "Pop"
|
|
|
|
}).snapshot();
|
|
|
|
});
|
2023-02-20 18:17:38 +00:00
|
|
|
|
2024-01-29 18:08:06 +00:00
|
|
|
it("works with numbers", () => {
|
|
|
|
cy.wrap(42).snapshot({
|
|
|
|
snapshotPath: "cypress/fixtures/snapshots",
|
|
|
|
snapshotName: "Numbers",
|
|
|
|
});
|
|
|
|
});
|
2023-02-20 18:17:38 +00:00
|
|
|
|
2024-01-29 18:08:06 +00:00
|
|
|
it("works with strings", () => {
|
|
|
|
cy.wrap("foo-bar").snapshot({
|
|
|
|
snapshotPath: "cypress/fixtures/snapshots",
|
|
|
|
snapshotName: "Strings",
|
|
|
|
});
|
|
|
|
});
|
2024-01-25 16:30:16 +00:00
|
|
|
|
2024-01-29 18:08:06 +00:00
|
|
|
it(
|
|
|
|
"works with arrays",
|
|
|
|
{
|
|
|
|
env: {
|
2024-01-31 08:22:07 +00:00
|
|
|
updateSnapshots: true,
|
2024-01-29 18:08:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
() => {
|
|
|
|
cy.wrap([1, 2, 3, 4]).snapshot({
|
|
|
|
snapshotPath: "cypress/fixtures/snapshots",
|
|
|
|
snapshotName: "Arrays",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2023-02-20 18:17:38 +00:00
|
|
|
|
2024-01-29 18:08:06 +00:00
|
|
|
});
|
|
|
|
context("complex types"
|
|
|
|
// , { env: { SNAPSHOT_UPDATE: true } }
|
|
|
|
, () => {
|
|
|
|
it('works with more "complicated" Objects', () => {
|
|
|
|
cy.wrap({
|
|
|
|
"status": 200,
|
|
|
|
"response": {
|
2024-01-31 18:49:52 +00:00
|
|
|
"array": [0, 1, 2, "4"],
|
2024-01-29 18:08:06 +00:00
|
|
|
"object": {
|
2024-02-01 13:45:03 +00:00
|
|
|
"with": "more details"
|
2024-01-29 18:08:06 +00:00
|
|
|
}
|
2024-01-31 18:49:52 +00:00
|
|
|
},
|
|
|
|
"thisisnew": "wtf"
|
|
|
|
}).snapshot()
|
2024-01-29 18:08:06 +00:00
|
|
|
})
|
|
|
|
it("works based on fixtures", () => {
|
|
|
|
cy
|
|
|
|
.wrap({
|
|
|
|
"jsonapi": {
|
|
|
|
"version": "2.0"
|
|
|
|
},
|
|
|
|
"included": [
|
|
|
|
{
|
|
|
|
"type": "users",
|
|
|
|
"id": "2",
|
|
|
|
"attributes": {
|
|
|
|
"name": "Test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.snapshot();
|
|
|
|
});
|
|
|
|
})
|
2023-02-20 18:17:38 +00:00
|
|
|
});
|