Output dir not created when is a nested directory
Hi,
When setting up the output directory as subdirectory of a non-existing directory, the application is not creating the tree before trying to save the screenshots:
Example:
"output": "./reports/integration/screenshots",
Should create reports, reports/integration/, reports/integration/screenshots if those doesn't exists.
At the moment the reporter is outputting this:
Uncaught ENOENT: no such file or directory, open [screenshotFile]
Where [screenshotFile] is the path to the screenshot.
Thanks!
I'm not sure we want Codecept to recursively create directories for output.
I'd rather have an existence test (fs.existsSync handles it pretty well) that would throw a warning, either:
- at initialization (in https://github.com/Codeception/CodeceptJS/blob/master/lib/codecept.js#L6,
fs.readdirSyncmethod is required but not used ?) - when trying to save the screenshots
Anyway we should catch the exception rather than crashing.
I could work on something if we agree on a clean solution, @DavertMik what do you think?
Yes, directory can be created but not readable, so we shouldn't guess weather we should create it or not. So I agree to @stephane-ruhlmann here. I think the check can be handled in very beginning (initialization), as output can be used not only for failures but for saveScreenshot as well.
Thanks for the suggestion. I will be waiting for your Pull Request )
Hey, Thing is basic reporters for Mocha / Karma or Protractor (screenshot / failures ) creates folders recursively if they don't exists then write the reports into, so that would be more consistent with the rest of the common tools present in the community. I agree that at least checking if the folders exists is a must to have if you want to keep the current strategy :).
@Nighthawk14 I'll check Mocha source code to see how they deal with recursive directory creation but it will probably be in a second time and subject to a second feature.
After upgrading to [email protected], I am facing a weird issue. The codecept "output" : "/Users/madhusus/hydra-dev/src/node_modules/consumer-automation/test-reports" value is appended to current test root path also. For eg : Actual folder where I want : /Users/madhusus/hydra-dev/src/node_modules/consumer-automation/test-reports (Passed in "output") Test Root Path : /Users/madhusus/hydra-dev/src/node_modules/nextgen-test/
What I am getting : /Users/madhusus/hydra-dev/src/node_modules/nextgen-test/Users/madhusus/hydra-dev/src/node_modules/consumer-automation/test-reports/desktop_browser_chrome_1
Why is it happening ? When I pass my custom path, why codecept should append the test root path also ? Can you please provide a solution for this ? Codecept is unable to create the directory.
Closing this issue. In 1.0.0 there is no problems to create output directories recursive