-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add visual regression tests for Aik using examples
- Loading branch information
Showing
14 changed files
with
254 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
rootUrl: "http://127.0.0.1:4444", | ||
gridUrl: "http://127.0.0.1:5555/wd/hub", | ||
|
||
browsers: { | ||
phantomjs: { | ||
desiredCapabilities: { | ||
browserName: "phantomjs" | ||
}, | ||
screenshotsDir: "./tests/visual-regression/references" | ||
} | ||
}, | ||
|
||
sets: { | ||
phantomjs: { | ||
files: ["tests/visual-regression/tests"], | ||
browsers: ["phantomjs"] | ||
} | ||
}, | ||
|
||
system: { | ||
plugins: { | ||
"html-reporter": { | ||
enabled: true, | ||
path: "tests/visual-regression/reports" | ||
} | ||
} | ||
} | ||
}; |
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
File renamed without changes.
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,57 @@ | ||
#!/bin/sh | ||
|
||
cd tests/heavy | ||
|
||
if [ ! -f "package.json" ]; then | ||
cp _package.json package.json | ||
fi | ||
|
||
print_header() { | ||
local color_title="\033[0;34m" | ||
local color_reset="\033[0m" | ||
local color_info="\033[1;33m" | ||
echo "" | ||
echo "${color_info}$1${color_reset}" | ||
echo "" | ||
} | ||
|
||
# | ||
# DEV SERVER | ||
# | ||
|
||
print_header "Thinkin in React -r" | ||
AIK_TEST=1 ./../../cli.js examples/thinking-in-react/src/index.js -r | ||
|
||
print_header "Thinkin in React -r -n -o" | ||
AIK_TEST=1 ./../../cli.js examples/thinking-in-react/src/index.js -r -n -o | ||
|
||
print_header "Simple Counter in Cycle.js" | ||
AIK_TEST=1 ./../../cli.js examples/simple-counter-cyclejs/src/index.js | ||
|
||
print_header "Simple Counter in Cycle.js -p" | ||
AIK_TEST=1 ./../../cli.js examples/simple-counter-cyclejs/src/index.js -p 3232 | ||
|
||
print_header "TodoMVC Vue" | ||
AIK_TEST=1 ./../../cli.js examples/todomvc-vue/src/index.js | ||
|
||
# | ||
# BUILD | ||
# | ||
|
||
print_header "Thinkin in React --build" | ||
AIK_TEST=1 ./../../cli.js examples/thinking-in-react/src/index.js --build -r | ||
|
||
print_header "Thinkin in React --build custom" | ||
AIK_TEST=1 ./../../cli.js examples/thinking-in-react/src/index.js --build custom -r | ||
|
||
print_header "Simple Counter in Cycle.js --build custom --base \"/test/\"" | ||
AIK_TEST=1 ./../../cli.js examples/simple-counter-cyclejs/src/index.js --build custom2 --base "/test/" | ||
|
||
print_header "Simple Counter in Cycle.js --build --base \"/test/\"" | ||
AIK_TEST=1 ./../../cli.js examples/simple-counter-cyclejs/src/index.js --build --base "/test/" | ||
|
||
# | ||
# AFTER RUN | ||
# | ||
|
||
cd ../.. |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
#!/bin/bash | ||
|
||
cd tests/heavy | ||
|
||
if [ -d "examples" ]; then | ||
cd examples | ||
git pull | ||
cd - | ||
else | ||
git clone https://github.com/d4rkr00t/aik-examples.git examples | ||
fi |
Binary file added
BIN
+7.2 KB
tests/visual-regression/references/Simple Counter in Cycle.js/plain/phantomjs.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.8 KB
tests/visual-regression/references/Thinking in React/plain/phantomjs.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,119 @@ | ||
const { spawn, execSync } = require("child_process"); | ||
const { join } = require("path"); | ||
const chalk = require("chalk"); | ||
const proq = require("proq"); | ||
|
||
const tests = [ | ||
{ | ||
pattern: "Thinking in React", | ||
args: ["examples/thinking-in-react/src/index.js", "-r"] | ||
}, | ||
{ | ||
pattern: "Simple Counter in Cycle.js", | ||
args: ["examples/simple-counter-cyclejs/src/index.js"] | ||
}, | ||
{ | ||
pattern: "TodoMVC Vue", | ||
args: ["examples/todomvc-vue/src/index.js"] | ||
} | ||
]; | ||
|
||
const command = process.argv[2] === "update" ? "update" : "test"; | ||
const suite = command === "update" ? null : process.argv[2]; | ||
|
||
function isReady(data) { | ||
return data && data.match(/Compiled/) && data.match(/Server:/); | ||
} | ||
|
||
function startPhantom(cb) { | ||
// eslint-disable-next-line | ||
console.log(`${chalk.blue("Starting PhantomJS...")}`); | ||
const phantomProcess = spawn("phantomjs", ["--webdriver=5555"], { | ||
env: process.env, | ||
cwd: process.cwd() | ||
}); | ||
let wasCalled = false; | ||
|
||
phantomProcess.stdout.on("data", () => { | ||
if (!wasCalled) { | ||
wasCalled = true; | ||
cb(phantomProcess); | ||
} | ||
}); | ||
} | ||
|
||
function runGeminiForPattern(pattern) { | ||
try { | ||
execSync( | ||
`./node_modules/.bin/gemini ${command} --grep "${pattern}" --reporter flat`, | ||
{ | ||
env: process.env, | ||
cwd: process.cwd(), | ||
stdio: "inherit" | ||
} | ||
); | ||
} catch (error) { | ||
return pattern; | ||
} | ||
} | ||
|
||
function runSingleTest(testConfig, result) { | ||
// eslint-disable-next-line | ||
console.log( | ||
`${chalk.blue("Running visual regression tests for:")} ${chalk.yellow( | ||
testConfig.pattern | ||
)}` | ||
); | ||
console.log(); // eslint-disable-line | ||
|
||
return new Promise(resolve => { | ||
const aikProcess = spawn("./../../cli.js", testConfig.args, { | ||
env: process.env, | ||
cwd: join(process.cwd(), "tests", "heavy") | ||
}); | ||
|
||
aikProcess.stdout.on("data", data => { | ||
if (isReady(data.toString())) { | ||
result.push(runGeminiForPattern(testConfig.pattern)); | ||
aikProcess.kill("SIGTERM"); | ||
|
||
console.log(); // eslint-disable-line | ||
|
||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function main() { | ||
startPhantom(phatomProcess => { | ||
const selectedTests = suite | ||
? tests.filter(t => t.pattern.startsWith(suite)) | ||
: tests; | ||
|
||
const promiseList = selectedTests.map(test => result => | ||
runSingleTest(test, result) | ||
); | ||
|
||
proq(promiseList, []).then(rawResults => { | ||
phatomProcess.kill("SIGTERM"); | ||
|
||
const results = rawResults.filter(r => !!r); | ||
|
||
console.log(chalk.dim("-----------------------")); // eslint-disable-line | ||
|
||
if (results.length) { | ||
console.log(); // eslint-disable-line | ||
results.map(result => | ||
// eslint-disable-next-line | ||
console.log(`${chalk.red("Error in:")} ${result}`) | ||
); | ||
process.exit(1); | ||
} else { | ||
console.log(chalk.green("DONE")); // eslint-disable-line | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
main(); |
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,12 @@ | ||
function test(suite) { | ||
suite.setUrl("/").setCaptureElements("body").capture("plain", actions => { | ||
actions | ||
.setWindowSize(800, 800) | ||
.wait(1000) | ||
.waitForElementToShow("body", 5000); | ||
}); | ||
} | ||
|
||
gemini.suite("Thinking in React", test); | ||
gemini.suite("Simple Counter in Cycle.js", test); | ||
gemini.suite("TodoMVC Vue", test); |