-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add a create-e2e command #115
Conversation
detox/local-cli/detox-create-e2e.js
Outdated
var fs = require('fs'); | ||
var dir = './e2e'; | ||
|
||
var mochaOptsContent= '--recursive --timeout 120000 --bail' |
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.
use const
instead of var
detox/local-cli/detox-create-e2e.js
Outdated
|
||
if (!fs.existsSync(dir)){ | ||
fs.mkdirSync(dir); | ||
fs.writeFileSync("./e2e/mocha.opts", mochaOptsContent, function(err) { |
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.
use arrow functions instead of function
detox/local-cli/detox-create-e2e.js
Outdated
after(async () => { | ||
await detox.cleanup(); | ||
});` | ||
var firstTestContent = `describe('Example', () => { |
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.
I think we should provide an empty firstTest.spec.js file.
something like:
describe('', () => {
beforeEach(async () => {
await device.reloadReactNative();
});
it('', async () => {
});
}
detox/local-cli/detox-create-e2e.js
Outdated
if(err) { | ||
return console.log(err); | ||
} | ||
console.log("The file was saved!"); |
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.
- We need a more descriptive log here, something like "Test files for were created in "
detox/local-cli/detox-create-e2e.js
Outdated
@@ -0,0 +1,60 @@ | |||
var fs = require('fs'); |
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.
add commander params to support multiple test runners (you can set mocha as default), and make it easy to add more templates for other test runners in the future.
This means moving all the templates to a different file (templates.mocha.js
?) and creating a switch like we have in detox-test.js
detox/local-cli/detox-create-e2e.js
Outdated
} | ||
console.log("The file was saved!"); | ||
}); | ||
fs.writeFileSync("./e2e/init.js", initjsContent, function(err) { |
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.
There's code duplication here, please create a function
detox/local-cli/detox-create-e2e.js
Outdated
}); | ||
fs.writeFileSync("./e2e/init.js", initjsContent, function(err) { | ||
if(err) { | ||
return console.log(err); |
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.
return the err
, not the console.log
Add a create-e2e command to create the e2e folder and the init.js, mocha.opts and myFirstTest.spec.js files inside it automatically