Skip to content

Commit

Permalink
Merge pull request #90 from dnbexperience/rc/dev
Browse files Browse the repository at this point in the history
optimize ci tests
  • Loading branch information
tujoworker authored Feb 14, 2019
2 parents d57847a + 400d411 commit a2462ba
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
LivePreview
} from 'react-live-replacement'
// we use this replacement, because;
// to simply have newer prism version for the LiveEditor
// to simply have newer prism version for the LiveEditor - I made a pull request.

// this theme is replaced my a css one
// import prismTheme from 'prism-react-renderer/themes/nightOwl'
Expand Down 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
4 changes: 0 additions & 4 deletions packages/dnb-ui-lib/jest-screenshot.json

This file was deleted.

2 changes: 2 additions & 0 deletions packages/dnb-ui-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"test-ci-screenshots": "jest --config=./jest.config.screenshots.js --ci --forceExit --detectOpenHandles",
"test:screenshots": "jest --config=./jest.config.screenshots.js --forceExit --detectOpenHandles",
"test:screenshots:build": "yarn build && yarn workspace dnb-design-system-portal build-portal && yarn test:screenshots",
"test:screenshots:recreate": "find . -name '*.snap.png' -type f|xargs rm -f && yarn test:screenshots",
"test:screenshots:update": "jest --config=./jest.config.screenshots.js --updateSnapshot --forceExit --detectOpenHandles",
"test:staged": "jest --bail --findRelatedTests ",
"test:update": "jest --updateSnapshot",
Expand Down Expand Up @@ -147,6 +148,7 @@
"jest-css-modules": "^1.1.0",
"jest-raw-loader": "^1.0.1",
"jest-screenshot": "^0.2.1",
"jest-screenshot-replacement": "https://github.com/tujoworker/jest-screenshot/tarball/fcf8414704f02716931889fa0a2047e58cad8adb",
"jest-tobetype": "^1.2.2",
"lint-staged": "^8.1.3",
"live-server": "^1.2.1",
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.
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.
24 changes: 17 additions & 7 deletions packages/dnb-ui-lib/src/core/jest/jestSetupScreenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ module.exports.testPageScreenshot = ({
{
id,
style: makeStyles({
'font-family': 'Arial',

position: 'relative',
'z-index': 9999,

Expand Down Expand Up @@ -170,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 @@ -194,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
4 changes: 3 additions & 1 deletion packages/dnb-ui-lib/src/core/jest/setupJestScreenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
*/

const isCI = require('is-ci')
const { setupJestScreenshot } = require('jest-screenshot')

// we use a replace for now to get this feature of sending the config in here. I made a pull request.
const { setupJestScreenshot } = require('jest-screenshot-replacement')

jest.setTimeout(30e3)

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.
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.
14 changes: 12 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11645,6 +11645,16 @@ jest-runtime@^24.1.0:
write-file-atomic "2.4.1"
yargs "^12.0.2"

"jest-screenshot-replacement@https://github.com/tujoworker/jest-screenshot/tarball/fcf8414704f02716931889fa0a2047e58cad8adb":
version "0.2.0"
resolved "https://github.com/tujoworker/jest-screenshot/tarball/fcf8414704f02716931889fa0a2047e58cad8adb#512c6c4a8544f0b24c15bccc651466f20fec5341"
dependencies:
chalk "^2.3.2"
lodash.kebabcase "^4.1.1"
mkdirp "^0.5.1"
native-image-diff "^0.1.1"
node-libpng "^0.2.0"

jest-screenshot@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/jest-screenshot/-/jest-screenshot-0.2.1.tgz#d3141805a61c7967d890135a3e5247aebc1f6d15"
Expand Down Expand Up @@ -13698,7 +13708,7 @@ napi-build-utils@^1.0.1:
resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.1.tgz#1381a0f92c39d66bf19852e7873432fc2123e508"
integrity sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==

native-image-diff@^0.1.7:
native-image-diff@^0.1.1, native-image-diff@^0.1.7:
version "0.1.8"
resolved "https://registry.yarnpkg.com/native-image-diff/-/native-image-diff-0.1.8.tgz#69ffd363603c106347643504556a766b2928625b"
integrity sha512-Hbdj4VIOGw2+UwBG8E9juaOQM8e/P3wqhJISsX2CK18j5LqlyKTC01oZgQKtbAooBr05wtag7jfQlYF8QV3Edg==
Expand Down Expand Up @@ -13858,7 +13868,7 @@ node-int64@^0.4.0:
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=

node-libpng@^0.2.6:
node-libpng@^0.2.0, node-libpng@^0.2.6:
version "0.2.7"
resolved "https://registry.yarnpkg.com/node-libpng/-/node-libpng-0.2.7.tgz#f69cf1eb6fb7d8c5005dc12e072b35447a194bff"
integrity sha512-A8ct3JfKQUFMI338l6N/58VYCRapM4/HR6tVjXyk/hKATC3Y1kQ9g3k2SxBg7nSJeJRNw+yXnUHwRSQeWbuCjA==
Expand Down

0 comments on commit a2462ba

Please sign in to comment.