-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest spike #66
Jest spike #66
Changes from 21 commits
06908a7
0af6a1f
66fd923
ac2a24c
be4955b
2d19b81
6aa9dc9
cfad2a8
8cf7382
97fb831
335bc09
274af5b
2b9c9f1
0ab7eda
b527452
e98239a
27c2b95
bdc0a8e
3f9b68a
3a7ed64
59af4f8
adba06e
47e2666
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.github-token | ||
bin/*.js | ||
bin/visreg.config.ts | ||
built/ | ||
index.js | ||
screenshots | ||
!built/functional/*.js.snap | ||
!built/functional/*.js.md | ||
screenshots |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Snapshot report for `built/functional/hx-reveal.js` | ||
|
||
The actual snapshot is saved in `hx-reveal.js.snap`. | ||
|
||
Generated by [AVA](https://ava.li). | ||
|
||
## should not be open | ||
|
||
> Snapshot 1 | ||
|
||
`<hx-reveal>␊ | ||
<span slot="summary">Click me to show content</span>␊ | ||
<p>You can't see me.</p>␊ | ||
</hx-reveal>` | ||
|
||
## should open | ||
|
||
> Snapshot 1 | ||
|
||
`<hx-reveal open="">␊ | ||
<span slot="summary">Click me to show content</span>␊ | ||
<p>You can't see me.</p>␊ | ||
</hx-reveal>` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {$, snap, Snappit, IConfig} from "snappit-visual-regression"; | ||
import {WebDriver, WebElementPromise} from "selenium-webdriver"; | ||
|
||
import {test, TestContext} from "ava"; | ||
|
||
const baseUrl = "http://localhost:3000/helix-ui"; | ||
const snapshot = async (t: TestContext, element: WebElementPromise) => { | ||
t.snapshot(await element.getAttribute("outerHTML")); | ||
}; | ||
|
||
let snappit: Snappit; | ||
let driver: WebDriver; | ||
let reveal: WebElementPromise; | ||
|
||
test.before(async () => { | ||
const config: IConfig = { | ||
browser: "chrome", | ||
serverUrl: "http://localhost:4444/wd/hub", | ||
}; | ||
|
||
snappit = new Snappit(config); | ||
driver = await snappit.start(); | ||
await driver.get(`${baseUrl}/components/reveal`); | ||
reveal = $(".demo hx-reveal"); | ||
}); | ||
|
||
test("should not be open", async t => { | ||
t.is(await reveal.getAttribute("open"), null); | ||
await snapshot(t, reveal); | ||
}); | ||
|
||
test("should open", async t => { | ||
await reveal.click(); | ||
t.is(await reveal.getAttribute("open"), "true"); | ||
await snapshot(t, reveal); | ||
}); | ||
|
||
test.after.always(async () => { | ||
await snappit.stop(); | ||
}); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
{ | ||
"dependencies": { | ||
"@types/chai": "^4.0.4", | ||
"@types/lodash": "^4.14.74", | ||
"@types/mocha": "^2.2.43", | ||
"@types/node": "^8.0.28", | ||
"@types/opn": "^3.0.28", | ||
"@types/reflect-metadata": "^0.0.5", | ||
"@types/selenium-webdriver": "^3.0.7", | ||
"chai": "^4.1.2", | ||
"ava": "^0.23.0", | ||
"inquirer-promise": "^1.0.0", | ||
"inquirer-shortcuts": "^1.1.0", | ||
"lodash": "^4.17.4", | ||
"mocha": "^3.5.3", | ||
"opn": "^5.1.0", | ||
"selenium-webdriver": "^3.5.0", | ||
"snappit-visual-regression": "^0.6.4", | ||
|
@@ -20,15 +17,21 @@ | |
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "npm run clean:js && npm run clean:screenshots", | ||
"clean:screenshots": "rm -rf screenshots", | ||
"clean:js": "rm -rf built/", | ||
"lint": "tslint index.ts", | ||
"test": "npm run build && mocha --timeout 15000 built/index.js", | ||
"previsreg": "[ -f ./bin/visreg.config.ts ] || cp bin/visreg{.example,}.config.ts", | ||
"visreg": "npm run clean:js && npm run build && node ./built/bin/util.js && node ./built/bin/visreg.js", | ||
"clean": "npm run clean:visreg && npm run clean:func", | ||
"clean:func": "find built/functional -mindepth 1 \\( ! -path 'built/functional/*.js.snap' ! -path 'built/functional/*.js.md' \\) -delete", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this gets any longer, move it into |
||
"clean:visreg": "rm -rf visreg/screenshots built/visreg", | ||
"lint": "tslint -c tslint.json visreg/ functional/", | ||
"test:func": "npm run build && ava built/functional/*.js", | ||
"test:visreg": "npm run build && ava built/visreg/{chrome,firefox}.js --verbose", | ||
"postinstall": "[ -f bin/visreg.config.ts ] || cp bin/visreg{.example,}.config.ts", | ||
"previsreg": "npm run clean:visreg", | ||
"visreg": "npm run build && node built/bin/util.js && node built/bin/visreg.js", | ||
"webdriver": "npm run webdriver:update && npm run webdriver:start", | ||
"webdriver:update": "scripts/webdriver-update", | ||
"webdriver:start": "scripts/webdriver-start" | ||
"webdriver:start": "scripts/webdriver-start", | ||
"webdriver:update": "scripts/webdriver-update" | ||
}, | ||
"ava": { | ||
"snapshotLocation": "~/code/js/helix-ui/test/snapshots", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoops. I left this in as a failed attempt to get This is not a working feature.... 👎 |
||
"failWithoutAssertions": false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,19 @@ | |
"types": [ | ||
"reflect-metadata", | ||
"node", | ||
"mocha" | ||
"ava" | ||
], | ||
"baseUrl": ".", | ||
"paths": { | ||
"*": ["types/*"] | ||
}, | ||
"outDir": "./built" | ||
"outDir": "built" | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": [ | ||
"index.ts", | ||
"bin/util.ts", | ||
"bin/visreg.ts", | ||
"bin/util.ts", | ||
"bin/visreg.config.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
"common/*.ts", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a single file in there right now. |
||
"functional/*.ts", | ||
"visreg/*.ts", | ||
"bin/*.ts" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as visreg from "./visreg"; | ||
|
||
visreg.suite("chrome"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as visreg from "./visreg"; | ||
|
||
visreg.suite("firefox"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {$, snap, Snappit, IConfig} from "snappit-visual-regression"; | ||
|
||
import * as util from "../common/util"; | ||
import {test} from "ava"; | ||
|
||
export function suite(browserName: string) { | ||
let snappit: Snappit; | ||
let driver: any; | ||
|
||
test.before(async () => { | ||
const config: IConfig = { | ||
browser: browserName, | ||
screenshotsDir: "visreg/screenshots", | ||
logException: [ | ||
"MISMATCH", | ||
"NO_BASELINE", | ||
"SIZE_DIFFERENCE", | ||
], | ||
threshold: 0.1, | ||
// serverUrl: "http://localhost:4444/wd/hub", | ||
useDirect: true, | ||
useGeckoDriver: (browserName === "firefox"), | ||
}; | ||
|
||
snappit = new Snappit(config); | ||
driver = await snappit.start(); | ||
await util.setViewportSize(driver, { width: 1366, height: 768 }); | ||
driver.get("http://localhost:3000/"); | ||
}); | ||
|
||
test(`nav`, async () => { | ||
await snap("{browserName}/nav", $(util.selectors.nav)); | ||
}); | ||
|
||
test(`guides`, async () => { | ||
await util.$x(driver, "//nav/hx-reveal//header", "Guides").click(); | ||
await snap("{browserName}/nav/guides", $(util.selectors.nav)); | ||
}); | ||
|
||
test(`components`, async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop the template literals. |
||
await util.$x(driver, "//nav/hx-reveal//header", "Components").click(); | ||
await snap("{browserName}/nav/componenets", $(util.selectors.nav)); | ||
}); | ||
|
||
test.after.always(async () => { | ||
await snappit.stop(); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we configure the newline characters in AVA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nm, I just realized that's on purpose to visualize new lines in the documentation