Search code examples
javascriptcucumbernightwatch.js

How to override the naming of on_failure screenshots?


Unfortunately due to using cucumber and writing out scenarios I end up with incredibly long file names which windows complains about. Is it possible to override the naming for the files?


Solution

  • I'm assuming you're using the Nightwatch framework since you've tagged it in your post.

    It looks like screenshot filenames are defined in nightwatch/lib/api/client-commands/end.js at line 26 of the latest repo const prefix = '${this.api.currentTest.module}/${this.api.currentTest.name}';.

    The screenshot path is defined in your nightwatch.json:

    {
      "test_settings" : {
        "default" : {
          "screenshots" : {
            "enabled" : true,
            "on_failure" : true,
            "path" : "./screens"
          }
        }
      }
    }
    

    It appears your have a few options:

    1. Modify the code in end.js to use a custom naming scheme, and live with a custom framework
    2. Shorten your test module names or test names
    3. Shorten your screenshot destination path in nightwatch.json - unlikely to solve anything since you're saying it's the filenames that are the problem.