diff --git a/src/cypress-api/commands.js b/src/cypress-api/commands.ts similarity index 87% rename from src/cypress-api/commands.js rename to src/cypress-api/commands.ts index 73cb7163..3d0b9bc6 100644 --- a/src/cypress-api/commands.js +++ b/src/cypress-api/commands.ts @@ -1,11 +1,14 @@ import { snapshot } from '@chromaui/rrweb-snapshot'; - +// @ts-ignore Cypress.Commands.add('takeChromaticArchive', () => { + // @ts-ignore cy.document().then((doc) => { // here, handle the source map const manualSnapshot = snapshot(doc, { noAbsolute: true }); // reassign manualSnapshots so it includes this new snapshot + // @ts-ignore cy.get('@manualSnapshots') + // @ts-ignore .then((snapshots) => { return [...snapshots, manualSnapshot]; }) diff --git a/src/cypress-api/index.js b/src/cypress-api/index.ts similarity index 100% rename from src/cypress-api/index.js rename to src/cypress-api/index.ts diff --git a/src/cypress-api/support.js b/src/cypress-api/support.ts similarity index 91% rename from src/cypress-api/support.js rename to src/cypress-api/support.ts index 2a1c306e..42c4c8f1 100644 --- a/src/cypress-api/support.js +++ b/src/cypress-api/support.ts @@ -6,19 +6,24 @@ const setupNetworkListener = () => { // these "archive" and "manualSnapshots" variables will be available before, during, and after the test, // then cleaned up before the next test is run // (see https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Aliases) + // @ts-ignore cy.wrap({}).as('archive'); + // @ts-ignore cy.wrap([]).as('manualSnapshots'); // since we don't know where the user will navigate, we'll archive whatever domain they're on first. + // @ts-ignore cy.intercept(`**/*`, (req) => { // don't archive the page itself -- we'll do that with rrweb // TODO: See if this will work for both slash and not slash endings or if we have to do same "first URL visited" stuff if (!pageUrl) { + // @ts-ignore pageUrl = new URL(req.url); return; } const url = new URL(req.url); + // @ts-ignore if (url.origin !== pageUrl.origin) { return; } @@ -30,7 +35,9 @@ const setupNetworkListener = () => { // I added this since some css files still are cached... not sure if this is great // (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304) delete req.headers['if-modified-since']; + // @ts-ignore req.continue((response) => { + // @ts-ignore cy.get('@archive').then((archive) => { archive[response.url] = { statusCode: response.statusCode, @@ -43,17 +50,23 @@ const setupNetworkListener = () => { }; const completeArchive = () => { + // @ts-ignore cy.get('@archive').then((archive) => { // can we be sure this always fires after all the requests are back? + // @ts-ignore cy.document().then((doc) => { const snap = snapshot(doc, { noAbsolute: true }); + // @ts-ignore cy.get('@manualSnapshots').then((manualSnapshots = []) => { // pass the snapshot to the server to write to disk + // @ts-ignore cy.task('archiveCypress', { + // @ts-ignore testTitle: Cypress.currentTest.title, domSnapshots: [...manualSnapshots, snap], resourceArchive: archive, chromaticStorybookParams: { + // @ts-ignore diffThreshold: Cypress.env('diffThreshold'), }, }); diff --git a/tsconfig.json b/tsconfig.json index cb2c35a1..768741c9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, - "allowJs": true, "baseUrl": ".", "emitDecoratorMetadata": true, "esModuleInterop": true,