Skip to content

Commit

Permalink
remove all require ts-node and jasmine.getEnv - refs #3
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Apr 15, 2021
1 parent 1b4e5b0 commit 30eda8a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
28 changes: 28 additions & 0 deletions protractor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,34 @@ module.exports = function transformer(file, api) {
)
})

/**
* remove all `require('ts-node')` and `jasmine.getEnv()`
*/
root.find(j.ExpressionStatement)
.filter((path) => {
if (
!path.value.expression.callee ||
!path.value.expression.callee.object
) {
return false
}
const expr = path.value.expression.callee.object
return (
(
expr.callee && expr.callee.name === 'require' &&
expr.arguments && expr.arguments[0].value === 'ts-node'
) ||
(
expr.callee &&
expr.callee.object &&
expr.callee.object.name === 'jasmine' &&
expr.callee.property.name === 'getEnv'
)
)
})
.remove()


/**
* remove command statements that aren't useful in WebdriverIO world
*/
Expand Down
8 changes: 7 additions & 1 deletion test/__fixtures__/protractor/source/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ exports.config = {
},
maxSessions: 321,
beforeLaunch: () => console.log('beforeLaunch hook'),
onPrepare: () => console.log('onPrepare hook'),
onPrepare: () => {
console.log('onPrepare hook')
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
},
onComplete: () => console.log('onComplete hook'),
onCleanUp: () => console.log('onCleanUp hook'),
afterLaunch: () => console.log('afterLaunch hook'),
Expand Down
6 changes: 5 additions & 1 deletion test/__fixtures__/protractor/transformed/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ exports.config = {

maxInstances: 321,
onPrepare: () => console.log('beforeLaunch hook'),
before: () => console.log('onPrepare hook'),

before: () => {
console.log('onPrepare hook')
},

after: () => console.log('onComplete hook'),
afterSession: () => console.log('onCleanUp hook'),
onComplete: () => console.log('afterLaunch hook'),
Expand Down

0 comments on commit 30eda8a

Please sign in to comment.