Skip to content

Commit

Permalink
Some ts-ignores removed
Browse files Browse the repository at this point in the history
  • Loading branch information
skitterm committed Oct 27, 2023
1 parent f40c5b6 commit 087ce2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/cypress-api/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { snapshot } from '@chromaui/rrweb-snapshot';
import type { elementNode } from '@chromaui/rrweb-snapshot';
// @ts-expect-error will fix when Cypress has its own package
Cypress.Commands.add('takeChromaticArchive', () => {
// @ts-expect-error will fix when Cypress has its own package
Expand All @@ -8,8 +9,7 @@ Cypress.Commands.add('takeChromaticArchive', () => {
// reassign manualSnapshots so it includes this new snapshot
// @ts-expect-error will fix when Cypress has its own package
cy.get('@manualSnapshots')
// @ts-expect-error will fix when Cypress has its own package
.then((snapshots) => {
.then((snapshots: elementNode[]) => {
return [...snapshots, manualSnapshot];
})
.as('manualSnapshots');
Expand Down
10 changes: 6 additions & 4 deletions src/cypress-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { elementNode } from '@chromaui/rrweb-snapshot';
import { writeTestResult } from '../write-archive';
import { SourceMapper } from '../utils/source-mapper';
import type { ChromaticStorybookParameters } from '../types';
import type { ResourceArchive } from '../resource-archive';

interface ArchiveParams {
testTitle: string;
domSnapshots: any[];
resourceArchive: any;
chromaticStorybookParams: any;
domSnapshots: elementNode[];
resourceArchive: ResourceArchive;
chromaticStorybookParams: ChromaticStorybookParameters;
}

const doArchive = async ({
Expand All @@ -26,7 +29,6 @@ const doArchive = async ({
return [
key,
{
// @ts-expect-error will fix when Cypress has its own package
...value,
// we can't use Buffer in the browser (when we collect the responses)
// so we go through one by one here and bufferize them
Expand Down
8 changes: 3 additions & 5 deletions src/cypress-api/support.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { snapshot } from '@chromaui/rrweb-snapshot';
import type { ResourceArchive } from '../resource-archive';
import './commands';

const setupNetworkListener = () => {
let pageUrl = '';
let pageUrl: URL | null = null;
// 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)
Expand All @@ -17,13 +18,11 @@ const setupNetworkListener = () => {
// 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-expect-error will fix when Cypress has its own package
pageUrl = new URL(req.url);
return;
}

const url = new URL(req.url);
// @ts-expect-error will fix when Cypress has its own package
if (url.origin !== pageUrl.origin) {
return;
}
Expand All @@ -39,8 +38,7 @@ const setupNetworkListener = () => {
req.continue((response) => {
// @ts-expect-error will fix when Cypress has its own package
cy.get('@archive')
// @ts-expect-error will fix when Cypress has its own package
.then((archive) => {
.then((archive: ResourceArchive) => {
const updatedArchive = {
...archive,
[response.url]: {
Expand Down

0 comments on commit 087ce2b

Please sign in to comment.