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

Safe directory creation #40

Closed
patrickhousley opened this issue Mar 28, 2016 · 1 comment
Closed

Safe directory creation #40

patrickhousley opened this issue Mar 28, 2016 · 1 comment

Comments

@patrickhousley
Copy link

Library is throwing an error when one or more of the parent directories of the path passed to reportDir does not exist.

Gulp task call:

gulp.task('test:execute', mochaTest({
  sources: paths.mochaTests,
  mochaOptions: {
    reporter: 'mochawesome',
    reporterOptions: {
      reportDir: paths.mochaReport,
      reportTitle: 'Core Build',
      inlineAssets: true
    }
  }
}));

Gulp task source:

export const mochaTest = (options = {}) => {
  let {
    sources = [],
    mochaOptions = {}
  } = options;

  return () => gulp.src(sources).pipe(mocha(mochaOptions));
}

Ouptut:

[mochawesome] Generating report files...

[16:46:34] 'test:execute' errored after 226 ms
[16:46:34] Error in plugin 'gulp-mocha'
Message:
    ENOENT: no such file or directory, mkdir '/Users/patrickhousley/Documents/projects/github/core-build/reports/mochaReport'
Details:
    errno: -2
    code: ENOENT
    syscall: mkdir
    path: /Users/patrickhousley/Documents/projects/github/core-build/reports/mochaReport
Stack:
Error: ENOENT: no such file or directory, mkdir '/Users/patrickhousley/Documents/projects/github/core-build/reports/mochaReport'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:842:18)
    at /Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/lib/reportGenerator.js:51:10
    at Array.forEach (native)
    at createDirs (/Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/lib/reportGenerator.js:49:8)
    at Array.async.auto.createDirs (/Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/lib/reportGenerator.js:19:9)
    at /Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/node_modules/async/lib/async.js:484:38
    at _each (/Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/node_modules/async/lib/async.js:46:13)
    at Object.async.auto (/Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/node_modules/async/lib/async.js:455:9)
    at generateReport (/Users/patrickhousley/Documents/projects/github/core-build/node_modules/mochawesome/lib/reportGenerator.js:15:9)
[16:46:34] 'test' errored after 528 ms
[16:46:34] Error in plugin 'run-sequence'
Message:
    An error occured in task 'test:execute'.
@adamgruber
Copy link
Owner

When using a custom directory for the report, mochawesome currently expects to only create one new directory. I'll see about modifying it so you can create multiple dirs if they don't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants