Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinjude committed May 16, 2022
1 parent 042692b commit 3582825
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import { Script, scripts } from "../../scripts"
import { Script, scripts } from "../../../gatsby-script-scripts"
import { ResourceRecord } from "../../records"

// The page that we will assert against
const page = `/scripts-with-sources`
const page = `/gatsby-script-scripts-with-sources`

Cypress.on(`window:before:load`, win => {
cy.spy(win, "requestIdleCallback").as("requestIdleCallback")
win.requestIdleCallback = undefined
})

beforeEach(() => {
// @ts-ignore Object.values does exist, Cypress wants ES5 in tsconfig
for (const script of [...Object.values(scripts), new RegExp(`framework`)]) {
cy.intercept(script, { middleware: true }, req => {
req.on(`before:response`, res => {
res.headers[`cache-control`] = `no-store` // Do not cache responses
})
})
}
})

/*
* Some browsers don't support the requestIdleCallback API, so we need to
* shim it. Here we test that the idle behaviour remains the same with shimmed requestIdleCallback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import { Script, scripts } from "../../scripts"
import { Script, scripts } from "../../gatsby-script-scripts"
import { ResourceRecord } from "../../records"

// The page that we will assert against
const page = `/scripts-with-sources`
const page = `/gatsby-script-scripts-with-sources`

Cypress.on(`window:before:load`, win => {
cy.spy(win, "requestIdleCallback").as("requestIdleCallback")
win.requestIdleCallback = undefined
})

beforeEach(() => {
// @ts-ignore Object.values does exist, Cypress wants ES5 in tsconfig
for (const script of [...Object.values(scripts), new RegExp(`framework`)]) {
cy.intercept(script, { middleware: true }, req => {
req.on(`before:response`, res => {
res.headers[`cache-control`] = `no-store` // Do not cache responses
})
})
}
})

/*
* Some browsers don't support the requestIdleCallback API, so we need to
* shim it. Here we test that the idle behaviour remains the same with shimmed requestIdleCallback
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-script/src/gatsby-script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useContext } from "react"
import { PartytownContext } from "./partytown-context"
import type { ReactElement, ScriptHTMLAttributes } from "react"
import type { PartytownProps } from "@builder.io/partytown/react"
import { requestIdleCallback } from "./request-idle-callback-shim"

export enum ScriptStrategy {
postHydrate = `post-hydrate`,
Expand Down

0 comments on commit 3582825

Please sign in to comment.