Skip to content
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

Merged
merged 12 commits into from
Apr 20, 2017
Merged

Add a create-e2e command #115

merged 12 commits into from
Apr 20, 2017

Conversation

bogobogo
Copy link
Contributor

Add a create-e2e command to create the e2e folder and the init.js, mocha.opts and myFirstTest.spec.js files inside it automatically

var fs = require('fs');
var dir = './e2e';

var mochaOptsContent= '--recursive --timeout 120000 --bail'
Copy link
Member

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


if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
fs.writeFileSync("./e2e/mocha.opts", mochaOptsContent, function(err) {
Copy link
Member

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

after(async () => {
await detox.cleanup();
});`
var firstTestContent = `describe('Example', () => {
Copy link
Member

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 () => {
 
   });
}

if(err) {
return console.log(err);
}
console.log("The file was saved!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We need a more descriptive log here, something like "Test files for were created in "

@@ -0,0 +1,60 @@
var fs = require('fs');
Copy link
Member

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

}
console.log("The file was saved!");
});
fs.writeFileSync("./e2e/init.js", initjsContent, function(err) {
Copy link
Member

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

});
fs.writeFileSync("./e2e/init.js", initjsContent, function(err) {
if(err) {
return console.log(err);
Copy link
Member

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

@bogobogo bogobogo merged commit b906082 into wix:master Apr 20, 2017
@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants