Skip to content

Commit

Permalink
Rename debug.log in after hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jeawhanlee committed Apr 4, 2024
1 parent 4140e38 commit 6c949f1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/support/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ BeforeAll(async function (this: ICustomWorld) {
* Before each test scenario without the @setup tag, performs setup tasks.
*/
Before({tags: 'not @setup'}, async function (this: ICustomWorld) {
const debugLogPath = `${WP_SSH_ROOT_DIR}wp-content/debug.log`;
const debugLogExists = await exists(debugLogPath);

if (debugLogExists && previousScenarioName) {
const newDebugLogPath = `${WP_SSH_ROOT_DIR}wp-content/debug-${previousScenarioName}.log`;
await rename(debugLogPath, newDebugLogPath);
}

/**
* To uncomment during implementation of cli
*/
Expand Down Expand Up @@ -192,6 +184,17 @@ After(async function (this: ICustomWorld, { pickle, result }) {
await this.utils.createScreenShot(this, pickle);
}

const debugLogPath = `${WP_SSH_ROOT_DIR}wp-content/debug.log`;
const debugLogExists = await exists(debugLogPath);

if (debugLogExists && previousScenarioName) {
// Close up white spaces.
previousScenarioName = previousScenarioName.toLowerCase();
previousScenarioName = previousScenarioName.replaceAll(' ', '-');
const newDebugLogPath = `${WP_SSH_ROOT_DIR}wp-content/debug-${previousScenarioName}.log`;
await rename(debugLogPath, newDebugLogPath);
}

await this.page?.close()
await this.context?.close()

Expand Down

0 comments on commit 6c949f1

Please sign in to comment.