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

App logs #200

Merged
merged 3 commits into from
Jul 17, 2017
Merged

App logs #200

merged 3 commits into from
Jul 17, 2017

Conversation

silyevsk
Copy link
Contributor

No description provided.

@silyevsk silyevsk self-assigned this Jul 16, 2017

it(`the constructor should catch exception from ArtifactsPathsProvider`, async () => {
mockCommandLineArgs({'artifacts-location': '/tmp'});
fs.mkdirSync = jest.fn(() => {throw 'Could not create artifacts root dir'});
Copy link
Member

Choose a reason for hiding this comment

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

Throw a new Error(''Could not create artifacts root dir') so we can follow the stack trace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@@ -30,6 +31,18 @@ class Detox {
this.userConfig = userConfig;
this.client = null;
this.device = null;
this._currentTestNumber = 0;
const artifactsLocation = argparse.getArgValue('artifacts-location');
if(artifactsLocation !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

why not use if(artifactsLocation) instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's unsafe in JS in general due to implicit type conversions, so I think it's better to never use it.. Here for instance, if a user supplies an empty string, like --artifacts-location '', then JS will convert artifactsLocation to false.

class ArtifactsPathsProvider {
constructor(destinationParent) {
if(!destinationParent) {
throw 'destinationParent should not be undefined';
Copy link
Member

Choose a reason for hiding this comment

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

throw new Error(''). I think this error string is not descriptive enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed


this.deviceDriver.validateDeviceConfig(deviceConfig);

this.relaunchApp = this.relaunchApp.bind(this);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need all those binds ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I probably don't need all of them, only those whose this is incorrect and is called from outside this. I guess I can reduce the list, but some will have to stay there

@@ -81,6 +82,10 @@
"functions": 100,
"lines": 100
}
}
},
Copy link
Member

Choose a reason for hiding this comment

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

Not sure excluding src/index.js is the right thing. This is something we can test, it's actually important that we do, till we have a sane type system, we want to make sure beforeEach and afterEach exist and that they don't crash the test if detox is undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, committed this by mistake, I actually added the the test for them, but forgot to remove the exclusion, will revert it.

@@ -23,7 +34,52 @@ class Device {
await this.relaunchApp({delete: !argparse.getArgValue('reuse')});
}

async _copyArtifacts() {
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 this is not the job of Device to move artifacts around. Why not merge all the logic in an ArtifactsHelper as you previously suggested ?

@silyevsk silyevsk merged commit 308e3ae into master Jul 17, 2017
@silyevsk silyevsk deleted the app_logs branch July 17, 2017 14:28
@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