Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

[terra-functional-testing] Updated specPath in BaseCompare. #644

Merged
merged 5 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/terra-functional-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Fixed
* Update specPath in BaseCompare to replace `node_modules` with `tests/wdio`.

## 1.2.0 - (April 23, 2021)

* Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class BaseCompare {

// Added to allow for test reusability from terra repositories
if (specPath.includes('node_modules')) {
[, specPath] = specPath.split('node_modules');
specPath = specPath.replace('node_modules', path.join('tests', 'wdio'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are no longer using Array.split() can we change specPath definition to

let specPath;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this.baseScreenshotDir as that is being used to add process.cwd(), which we are removing at the specPath definition using Array.split()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was doing the pretty much the same thing as in terra-toolkit-boneyard. I wonder where the difference is between the two.

}

const baseScreenshotPath = path.join(this.baseScreenshotDir, specPath, '__snapshots__');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ describe('BaseCompare', () => {
...context,
test: {
...context.test,
file: path.join(process.cwd(), 'node_modules', 'test', 'wdio', 'test-spec.js'),
file: path.join(process.cwd(), 'node_modules', 'packageName', 'test', 'wdio', 'test-spec.js'),
},
};
const result = baseCompare.getScreenshotPaths(updatedContext);
expect(result.referencePath).toEqual(path.join(process.cwd(), 'test', 'wdio', '__snapshots__', 'reference', 'screenshotDir', 'screenshotName.png'));
expect(result.latestPath).toEqual(path.join(process.cwd(), 'test', 'wdio', '__snapshots__', 'latest', 'screenshotDir', 'screenshotName.png'));
expect(result.diffPath).toEqual(path.join(process.cwd(), 'test', 'wdio', '__snapshots__', 'diff', 'screenshotDir', 'screenshotName.png'));
expect(result.referencePath).toEqual(path.join(process.cwd(), 'tests', 'wdio', 'packageName', 'test', 'wdio', '__snapshots__', 'reference', 'screenshotDir', 'screenshotName.png'));
expect(result.latestPath).toEqual(path.join(process.cwd(), 'tests', 'wdio', 'packageName', 'test', 'wdio', '__snapshots__', 'latest', 'screenshotDir', 'screenshotName.png'));
expect(result.diffPath).toEqual(path.join(process.cwd(), 'tests', 'wdio', 'packageName', 'test', 'wdio', '__snapshots__', 'diff', 'screenshotDir', 'screenshotName.png'));
});
});

Expand Down