Skip to content

Commit

Permalink
ci screenshot testing: block fonts from the very start
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Feb 14, 2019
1 parent 0edbb6a commit e2e037b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class LiveCode extends PureComponent {
(typeof window !== 'undefined' &&
!(
window.location &&
window.location.search.split(/\?|&/).includes('test')
window.location.search.split(/\?|&/).includes('data-dnb-test')
))
) {
code = code.replace(/\s+data-dnb-test="[^"]*"/g, '')
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions packages/dnb-ui-lib/src/core/jest/jestSetupScreenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,21 @@ module.exports.setupPageScreenshot = ({ timeout, url, ...rest } = {}) => {
const context = await global.__BROWSER__.createIncognitoBrowserContext()
const page = await context.newPage()

// await page._client.send('ServiceWorker.enable')
// await page._client.send('ServiceWorker.stopAllWorkers')
// await page._client.send('ServiceWorker.unregister', {
// scopeURL: `http://${testScreenshotOnHost}:${testScreenshotOnPort}`
// })

await page.setViewport(pageSettings)

await page.setRequestInterception(true) // is needed in order to use on "request"
page.on('request', req => {
const type = req.resourceType()
switch (type) {
case 'font':
req.abort()
break

default:
req.continue()
}
})

await page.goto(useUrl)

global.__PAGE__ = page
Expand All @@ -196,7 +204,7 @@ module.exports.loadImage = async imagePath =>

// make sure "${url}/" has actually a slash on the end
const createUrl = url =>
`http://${testScreenshotOnHost}:${testScreenshotOnPort}/${url}/?fullscreen&test`.replace(
`http://${testScreenshotOnHost}:${testScreenshotOnPort}/${url}/?data-dnb-test&fullscreen`.replace(
/\/\//g,
'/'
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2e037b

Please sign in to comment.