-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from chromaui/steven/cypress-options
Chromatic options for Cypress
- Loading branch information
Showing
11 changed files
with
233 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
it('Options / delay', { env: { delay: 1200 } }, () => { | ||
cy.visit('/options/delay'); | ||
}); | ||
|
||
it('Options / diff threshold', { env: { diffThreshold: 1 } }, () => { | ||
cy.visit('/options/diff-threshold'); | ||
}); | ||
|
||
it('Options / pause animation at end', { env: { pauseAnimationAtEnd: true } }, () => { | ||
cy.visit('/options/pause-animation-at-end'); | ||
}); | ||
|
||
it('Options / force high-contrast', { env: { forcedColors: 'active' } }, () => { | ||
cy.visit('/options/forced-colors'); | ||
}); | ||
|
||
it('Options / prefers reduced motion', { env: { prefersReducedMotion: 'reduce' } }, () => { | ||
cy.visit('/options/prefers-reduced-motion'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { test } from '../src'; | ||
|
||
test.describe(() => { | ||
test.use({ delay: 1200 }); | ||
|
||
test('Options / delay', async ({ page }) => { | ||
await page.goto('/options/delay'); | ||
}); | ||
}); | ||
|
||
test.describe(() => { | ||
test.use({ diffThreshold: 1 }); | ||
|
||
test('Options / diff threshold', async ({ page }) => { | ||
await page.goto('/options/diff-threshold'); | ||
}); | ||
}); | ||
|
||
test.describe(() => { | ||
test.use({ pauseAnimationAtEnd: true }); | ||
|
||
test('Options / pause animation at end', async ({ page }) => { | ||
await page.goto('/options/pause-animation-at-end'); | ||
}); | ||
}); | ||
|
||
test.describe(() => { | ||
test.use({ forcedColors: 'active' }); | ||
|
||
test('Options / force high-contrast', async ({ page }) => { | ||
await page.goto('/options/forced-colors'); | ||
}); | ||
}); | ||
|
||
test.describe(() => { | ||
test.use({ prefersReducedMotion: 'reduce' }); | ||
|
||
test('Options / prefers reduced motion', async ({ page }) => { | ||
await page.goto('/options/prefers-reduced-motion'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<style> | ||
/* don't show the image at the beginning */ | ||
img { | ||
visibility: hidden; | ||
animation-name: make-shown; | ||
animation-duration: 2ms; | ||
animation-delay: 1000ms; | ||
animation-fill-mode: forwards; | ||
} | ||
|
||
@keyframes make-shown { | ||
0% { | ||
visibility: hidden; | ||
} | ||
100% { | ||
visibility: visible; | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<img src="/img?url=fixtures/blue.png"/> | ||
<h4>The image should be snapshotted since we're waiting until the delayed-revealed image is visible.</h4> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<style> | ||
h1 { | ||
font-family: monospace; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1></h1> | ||
<h4>Number above should have no diff, even though it switches between 6 and 8, since the diff threshold is so high</h4> | ||
|
||
<script> | ||
const randomInteger = Math.ceil(Math.random() * 10); | ||
const isEven = randomInteger % 2 === 0; | ||
// number is either 6 or 8... should always have no diff since diff threshold is so high | ||
// and those 2 numbers are very similar in look | ||
document.querySelector('h1').innerText = isEven ? 8 : 6; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<style> | ||
h1 { | ||
color: #eee; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>This title is hard to read without high-contrast mode.</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<style> | ||
img { | ||
opacity: 0; | ||
animation-name: make-shown; | ||
/* image takes awhile to fade in */ | ||
animation-duration: 2s; | ||
animation-fill-mode: forwards; | ||
} | ||
|
||
@keyframes make-shown { | ||
0% { | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<img src="/img?url=fixtures/blue.png"/> | ||
<h4>The image should be snapshotted since we're forcing animations to the end (when the image is fully opaque).</h4> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<style> | ||
h1 { | ||
visibility: hidden; | ||
} | ||
|
||
@media (prefers-reduced-motion) { | ||
h1 { | ||
visibility: visible; | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>This message should appear when prefers-reduced-motion is enabled.</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters