Skip to content

Commit

Permalink
fix: an issue with metadata
Browse files Browse the repository at this point in the history
When specifying the path to the Cypress config located outside the root directory, metadata was not added to the test case.
  • Loading branch information
gibiw committed Nov 11, 2024
1 parent 99f8455 commit 15281e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions qase-cypress/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [email protected]

## What's new

Fixed an issue with metadata. When specifying the path to the Cypress config located outside the root directory, metadata was not added to the test case.

# [email protected]

## What's new
Expand Down
2 changes: 1 addition & 1 deletion qase-cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-qase-reporter",
"version": "2.2.1",
"version": "2.2.2",
"description": "Qase Cypress Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"sideEffects": false,
Expand Down
12 changes: 6 additions & 6 deletions qase-cypress/src/metadata/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { v4 as uuidv4 } from 'uuid';
import path from 'path';
import { Attachment, getMimeTypes } from 'qase-javascript-commons';

const metadataPath = 'qaseMetadata';

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class MetadataManager {
static metadataPath = path.resolve(__dirname, 'qaseMetadata');

public static getMetadata(): Metadata | undefined {
if (!this.isExists()) {
return undefined;
Expand All @@ -29,7 +29,7 @@ export class MetadataManager {
};

try {
const data = readFileSync(metadataPath, 'utf8');
const data = readFileSync(this.metadataPath, 'utf8');
metadata = JSON.parse(data) as Metadata;

return metadata;
Expand Down Expand Up @@ -143,7 +143,7 @@ export class MetadataManager {
private static setMetadata(metadata: Metadata): void {
try {
const data = JSON.stringify(metadata);
writeFileSync(metadataPath, data);
writeFileSync(this.metadataPath, data);
} catch (err) {
console.error('Error writing metadata file:', err);
}
Expand All @@ -155,14 +155,14 @@ export class MetadataManager {
}

try {
unlinkSync(metadataPath);
unlinkSync(this.metadataPath);
} catch (err) {
console.error('Error clearing state file:', err);
}
}

static isExists(): boolean {
return existsSync(metadataPath);
return existsSync(this.metadataPath);
}

static prepareAttach(attach: Attach): Attachment[] {
Expand Down

0 comments on commit 15281e7

Please sign in to comment.