Skip to content

Commit

Permalink
feat(tees-drivers): enhance tees drivers for extensibility
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Oct 7, 2019
1 parent 5e79b96 commit 1ef41c4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
16 changes: 15 additions & 1 deletion packages/tees-environment/src/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,25 @@ function checkValidBrowsers(process) {
}

const createDriver = (name, inputSetting = {}) => {
const {
let config;
try {
const { globals } = getConfig(process);
// eslint-disable-next-line
config = require(globals.configPath);
} catch (error) {
console.error(error);
process.exit();
return;
}
let {
Driver,
setting,
Query
} = e2eDrivers[name];
if (config && config.drivers && config.drivers[name]) {
Driver = config.drivers[name].Driver || Driver;
Query = config.drivers[name].Query || Query;
}
// TDDO inputSetting for browser
const options = {
driver: {
Expand Down
7 changes: 7 additions & 0 deletions packages/tees-integration/e2e.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { Query } = require('./integration-test/lib/puppeteerQuery');

module.exports = {
selectorLabel: 'class',
params: {
Expand All @@ -8,6 +10,11 @@ module.exports = {
}
}
},
drivers: {
puppeteer: {
Query,
}
},
lookupConfig({
config,
tag
Expand Down
2 changes: 1 addition & 1 deletion packages/tees-integration/integration-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ describe('Default page', () => {
title: 'check text include "Learn React" in default page',
}, async ({ page }) => {
const text = await $(page).getText('@App-link');
expect(text).toMatch('Learn React');
expect(text).toEqual('Learn React');
});
});
13 changes: 13 additions & 0 deletions packages/tees-integration/integration-test/lib/puppeteerQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { Query: BaseQuery } = require('tees-drivers/src/puppeteer');

class Query extends BaseQuery {
async getText(...args) {
return await super.getText(...args);
}
}

module.exports = {
Query,
};


3 changes: 2 additions & 1 deletion packages/tees-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"build": "node scripts/build.js",
"forever:start": "forever start scripts/start.js",
"forever:stop": "forever stop scripts/start.js",
"test": "yarn forever:start && wait-on tcp:3000 && tees run integration-test/** -H && yarn forever:stop"
"test:tees": "tees run integration-test/** -H",
"test": "yarn forever:start && wait-on tcp:3000 && yarn test:tees && yarn forever:stop"
},
"eslintConfig": {
"extends": "react-app"
Expand Down

0 comments on commit 1ef41c4

Please sign in to comment.