Skip to content

Commit

Permalink
Files back to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
skitterm committed Oct 27, 2023
1 parent 3ed7d02 commit aa70114
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/cypress-api/commands.js → src/cypress-api/commands.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { snapshot } from '@chromaui/rrweb-snapshot';

// @ts-ignore

Check failure on line 2 in src/cypress-api/commands.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
Cypress.Commands.add('takeChromaticArchive', () => {
// @ts-ignore

Check failure on line 4 in src/cypress-api/commands.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
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

Check failure on line 9 in src/cypress-api/commands.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
cy.get('@manualSnapshots')
// @ts-ignore

Check failure on line 11 in src/cypress-api/commands.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
.then((snapshots) => {
return [...snapshots, manualSnapshot];
})
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions src/cypress-api/support.js → src/cypress-api/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 9 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
cy.wrap({}).as('archive');
// @ts-ignore

Check failure on line 11 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
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

Check failure on line 15 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
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

Check failure on line 20 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
pageUrl = new URL(req.url);
return;
}

const url = new URL(req.url);
// @ts-ignore

Check failure on line 26 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
if (url.origin !== pageUrl.origin) {
return;
}
Expand All @@ -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

Check failure on line 38 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / test

Do not use "@ts-ignore" because it alters compilation errors
req.continue((response) => {
// @ts-ignore
cy.get('@archive').then((archive) => {
archive[response.url] = {
statusCode: response.statusCode,
Expand All @@ -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'),
},
});
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowJs": true,
"baseUrl": ".",
"emitDecoratorMetadata": true,
"esModuleInterop": true,
Expand Down

0 comments on commit aa70114

Please sign in to comment.