Skip to content

Commit

Permalink
fixed tests: changed runner from mocha to tap and added script to kil…
Browse files Browse the repository at this point in the history
…l the tunnel
  • Loading branch information
zouhir committed Jun 11, 2020
1 parent 6a5a8d7 commit 494286f
Show file tree
Hide file tree
Showing 9 changed files with 3,755 additions and 1,161 deletions.
1 change: 1 addition & 0 deletions .nyc_output/031dbeba-e99a-479f-8cb1-ca815b7300ee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/cb1b106e-19e4-4fe7-97a9-2f53fc647436.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"uuid":"031dbeba-e99a-479f-8cb1-ca815b7300ee","parent":"cb1b106e-19e4-4fe7-97a9-2f53fc647436","pid":12522,"argv":["/Users/zouhir/.nvm/versions/node/v13.12.0/bin/node","/Users/zouhir/Projects/scroll-timeline/test/webdriver/index.js"],"execArgv":["-r","/Users/zouhir/Projects/scroll-timeline/node_modules/esm/esm.js"],"cwd":"/Users/zouhir/Projects/scroll-timeline","time":1591909275351,"ppid":12507,"root":"9b474c58-2175-44f4-925c-a935bcae1a0a","coverageFilename":"/Users/zouhir/Projects/scroll-timeline/.nyc_output/031dbeba-e99a-479f-8cb1-ca815b7300ee.json","externalId":"test/webdriver/index.js","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"uuid":"cb1b106e-19e4-4fe7-97a9-2f53fc647436","parent":null,"pid":12507,"argv":["/Users/zouhir/.nvm/versions/node/v13.12.0/bin/node","/Users/zouhir/Projects/scroll-timeline/node_modules/.bin/tap","test/webdriver/index.js"],"execArgv":[],"cwd":"/Users/zouhir/Projects/scroll-timeline","time":1591909272525,"ppid":12489,"root":"9b474c58-2175-44f4-925c-a935bcae1a0a","coverageFilename":"/Users/zouhir/Projects/scroll-timeline/.nyc_output/cb1b106e-19e4-4fe7-97a9-2f53fc647436.json","files":[]}
1 change: 1 addition & 0 deletions .nyc_output/processinfo/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"processes":{"031dbeba-e99a-479f-8cb1-ca815b7300ee":{"parent":"cb1b106e-19e4-4fe7-97a9-2f53fc647436","externalId":"test/webdriver/index.js","children":[]},"cb1b106e-19e4-4fe7-97a9-2f53fc647436":{"parent":null,"children":["031dbeba-e99a-479f-8cb1-ca815b7300ee"]}},"files":{},"externalIds":{"test/webdriver/index.js":{"root":"031dbeba-e99a-479f-8cb1-ca815b7300ee","children":[]}}}
4,814 changes: 3,678 additions & 1,136 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"test:setup:wpt": "./test/setup/wpt-repo.sh",
"test:run:local-simple": "npm run test:setup:wpt && npm run serve:wpt",
"test:run:local-webdriver": "npm run test:setup:wpt && npm run test:run:webdriver",
"test:kill-sc-tunnel": "ps aux | grep sc | grep -v grep | awk '{print $2}' | xargs kill -9",
"test:setup:ci": "npm run test:setup:wpt && ./test/setup/start-tunnel.sh",
"test:run:webdriver": "mocha test/webdriver/index.js --delay --exit"
"test:run:webdriver": "tap test/webdriver/index.js --no-coverage --timeout=240"
},
"repository": {
"type": "git",
Expand All @@ -40,15 +41,14 @@
},
"homepage": "https://github.com/flackr/scroll-timeline#readme",
"devDependencies": {
"chai": "^4.2.0",
"dotenv": "^8.2.0",
"gh-pages": "^2.2.0",
"microbundle": "^0.12.0-next.8",
"mocha": "^7.2.0",
"run-all": "^1.0.1",
"selenium-webdriver": "^4.0.0-alpha.7",
"sirv": "^0.4.6",
"sirv-cli": "^0.4.5"
"sirv-cli": "^0.4.5",
"tap": "^14.10.7"
},
"dependencies": {}
}
20 changes: 19 additions & 1 deletion test/tests.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
"/polyfills/scroll-timeline.js"
],
"harnessTests": [
"/scroll-animations/current-time-nan.html"
"/scroll-animations/current-time-nan.html",
"/scroll-animations/current-time-root-scroller.html",
"/scroll-animations/current-time-writing-modes.html",
"/scroll-animations/current-time.html",
"/scroll-animations/scroll-animation.html",
"/scroll-animations/scroll-timeline-invalidation.html",
"/scroll-animations/scroll-timeline-phases.tentative.html",
"/scroll-animations/setting-current-time.html",
"/scroll-animations/setting-playback-rate.html"
],
"browsers": {
"local": [
Expand All @@ -14,6 +22,16 @@
"browserName": "MicrosoftEdge",
"browserVersion": "latest",
"platformName": "Windows 10"
},
"chrome": {
"browserName": "chrome",
"browserVersion": "latest",
"platformName": "Windows 10"
},
"firefox": {
"browserName": "firefox",
"platformName": "Windows 10",
"browserVersion": "latest"
}
}
}
Expand Down
69 changes: 49 additions & 20 deletions test/webdriver/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
require("dotenv").config();
const expect = require("chai").expect;
const webdriver = require("selenium-webdriver");
const builder = require('./driver-builder');
const sirv = require("sirv");
const {createServer} = require("http");

const {harnessTests} = require("../tests.config.json");

const {exec} = require("child_process");

const t = require('tap')

let server;

// TODO: configure / accept as cli args
const port = 8081;
const origin = "localhost"

// firefox requires a protocol even for localhost origins
const baseUrl = `http://${origin}:${port}`;
const WPT_DIR = process.env.WPT_DIR || ".";
Expand All @@ -36,7 +42,7 @@ async function testPage(driver, testPath) {

async function startServer() {

let server = createServer(sirv(WPT_DIR, {quite: true}));
server = createServer(sirv(WPT_DIR, {quite: true}));

return new Promise((resolve, reject) => {
server.listen(port, origin, err => {
Expand All @@ -49,7 +55,7 @@ async function startServer() {
})
}

async function main() {
async function runWebDriverTests() {
//TODO: convert JavaScript's rejection handling from try{}catch{} to:
// let [resolved, rejected] = await fn()
try {
Expand All @@ -75,26 +81,49 @@ async function main() {
testResults.set(browser, currentBrowserResults)
}
return new Promise((resolve) => {
resolve(testResults)
server.close(() => {
resolve(testResults);
})
})
}

main().then(testResults => {
describe("WPT Harness Tests + ScrollTimeline polyfill", function () {
this.timeout(80000);
testResults.forEach((browserResults, browser) => {
describe(`Running on ${browser} browser`, () => {

t.test("WPT Harness Tests + ScrollTimeline polyfill", parentTest => {
// TODO: switch to a less callback-y async-await syntax
// https://node-tap.org/docs/api/promises/#promises
runWebDriverTests().then(results => {
results.forEach((browserResults, browser) => {
parentTest.test(`Running on ${browser} browser`, vendorTest => {
Object(browserResults).forEach(suit => {
describe(suit.test, () => {
suit.tests.forEach(t => {
it(t.name, () => {
expect(t.status, `${t.message}`).to.equal(0);
})
})
})
})
vendorTest.test(suit.test, harnessPageTest => {
suit.tests.forEach(item => {
harnessPageTest.test(item.name, harnessSubTest => {
harnessSubTest.equal(item.status, 0, item.message);
harnessSubTest.end();
});
});
harnessPageTest.end();
});
});
vendorTest.end();
});
})
})
run()
});
parentTest.end();
});
});

t.tearDown(() => {
if( builder.isSaucelabsTest === true ) {
exec("ps aux | grep sc | grep -v grep | awk '{print $2}' | xargs kill -9", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
}
})

0 comments on commit 494286f

Please sign in to comment.