CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Output dir not created when is a nested directory

Open Nighthawk14 opened this issue 10 years ago • 6 comments

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!

Nighthawk14 avatar Jul 25 '16 07:07 Nighthawk14

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.readdirSync method 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?

stephane-ruhlmann avatar Aug 02 '16 14:08 stephane-ruhlmann

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 )

DavertMik avatar Aug 03 '16 23:08 DavertMik

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 avatar Aug 04 '16 00:08 Nighthawk14

@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.

stephane-ruhlmann avatar Aug 04 '16 09:08 stephane-ruhlmann

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.

shrikanthkm07 avatar Jun 23 '17 13:06 shrikanthkm07

Closing this issue. In 1.0.0 there is no problems to create output directories recursive

APshenkin avatar Jul 25 '17 11:07 APshenkin