Skip to content

How To Clear Output Folder That Saves The Failed Cases Snapshot #867

Closed

Description

@ninpop25

I am running my test cases on client server Via Jenkins and I want that each time when I Run my Tests then Output folder is cleaned and then when tests finishes all those failed cases snapshots are attached and sent in Build Report Email

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

# paste output here

Provide test source code if related

// paste test

Details

  • CodeceptJS version:
  • NodeJS Version:
  • Operating System:
  • Protractor || WebDriverIO || Nightmare version (if related)
  • Configuration file:
# paste suite config here

Activity

  1. DavertMik commented on Jan 11, 2018

    @DavertMik
    Contributor

    This can be done with Jenkins without CodeceptJS

    Just add rm -rf tests/output/* before executing tests.

    And please don't spam in Twitter. That doesn't sound like a good manner.

  2. ninpop25 commented on Jan 12, 2018

    @ninpop25
    Author

    @DavertMik : Thanks for reply,I forgot to inform you that my Server is Windows 10 Machine,so request you to please tell me the command for windows that deletes all Sub Folders and Files Inside Output Directory .

    Also please let me know that how this Output folder that contains snapshots ,will be attached in Build Report mail?

    I am really sorry for Spamming twitter ,will not do it again.

    Thanks once again for quick response

  3. schmkr commented on Jan 2, 2019

    @schmkr

    FYI Here's an example on how I just set this up using the bootstrap configuration:

    "bootstrap": function(done) {
        try {
            const {ctimeMs} = fs.statSync(OUTPUT_PATH);
            fs.renameSync(OUTPUT_PATH, `${OUTPUT_PATH}_${ctimeMs}`);
        } catch(error) {
            console.error('Could not rename output path');
            console.log(error);
        }
    
        done();
    },
    

    I choose to rename the old output folder instead of deleting it, deleting it might require using glob or launching a sub-process that is aware of the OS.

    OUTPUT_PATH is a variable defined on top of the configuration file, that is used both in this bootstrap function and in the output configuration. Not sure if there is a way to get the current configuration of Codecept as a parameter to the bootstrap function?

  4. schmkr commented on Jan 2, 2019

    @schmkr

    🤔 Forget that, it seems doing this in the bootstrap function, the output dir is renamed during the run 😞

  5. aesyondu commented on Nov 27, 2020

    @aesyondu

    Here is how I did it for 3.0.2, in case someone comes here from search engine:

    // codecept.conf.js
    const rimraf = require("rimraf");
    const outputFolder = "./test/e2e/bdd/.tmp";
    
    exports.config = {
      // ... irrelevant code
      output: outputFolder,
      async bootstrap() {
        await new Promise((resolve, reject) => {
          rimraf(outputFolder, (err) => {
            if (err) {
              reject(err);
            } else {
              resolve();
            }
          });
        });
      },
      // ... irrelevant code
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions