1
- import { it , expect , describe } from " vitest" ;
2
- import path from " path" ;
3
- import { promises as fs , existsSync } from "fs" ;
1
+ import { it , expect , describe } from ' vitest' ;
2
+ import path from ' path' ;
3
+ import { promises as fs , existsSync } from 'fs' ;
4
4
import {
5
5
initAfterScreenshotHook ,
6
6
parseAbsolutePath ,
7
- } from " ./afterScreenshot.hook" ;
8
- import { dir , file , setGracefulCleanup } from " tmp-promise" ;
9
- import { IMAGE_SNAPSHOT_PREFIX , PATH_VARIABLES } from " ./constants" ;
7
+ } from ' ./afterScreenshot.hook' ;
8
+ import { dir , file , setGracefulCleanup } from ' tmp-promise' ;
9
+ import { IMAGE_SNAPSHOT_PREFIX , PATH_VARIABLES } from ' ./constants' ;
10
10
11
11
setGracefulCleanup ( ) ;
12
12
13
- describe ( " initAfterScreenshotHook" , ( ) => {
14
- it ( " move file and remove old directories" , async ( ) => {
13
+ describe ( ' initAfterScreenshotHook' , ( ) => {
14
+ it ( ' move file and remove old directories' , async ( ) => {
15
15
const { path : screenshotsFolder } = await dir ( ) ;
16
16
const imagesFolder = path . join ( screenshotsFolder , IMAGE_SNAPSHOT_PREFIX ) ;
17
17
await fs . mkdir ( imagesFolder ) ;
@@ -22,11 +22,11 @@ describe("initAfterScreenshotHook", () => {
22
22
screenshotsFolder,
23
23
projectRoot,
24
24
} as Cypress . PluginConfigOptions ) ( {
25
- name : IMAGE_SNAPSHOT_PREFIX + path . sep + " some_name" ,
25
+ name : IMAGE_SNAPSHOT_PREFIX + path . sep + ' some_name' ,
26
26
path : imgPath ,
27
27
} as Cypress . ScreenshotDetails ) ;
28
28
29
- const expectedNewPath = path . join ( projectRoot , " some_name" ) ;
29
+ const expectedNewPath = path . join ( projectRoot , ' some_name' ) ;
30
30
expect ( existsSync ( imagesFolder ) ) . toBe ( false ) ;
31
31
expect ( existsSync ( imgPath ) ) . toBe ( false ) ;
32
32
expect ( existsSync ( expectedNewPath ) ) . toBe ( true ) ;
@@ -35,32 +35,32 @@ describe("initAfterScreenshotHook", () => {
35
35
} ) ;
36
36
} ) ;
37
37
38
- describe ( " parseAbsolutePath" , ( ) => {
39
- const projectRoot = " /its/project/root" ;
38
+ describe ( ' parseAbsolutePath' , ( ) => {
39
+ const projectRoot = ' /its/project/root' ;
40
40
41
- it ( " resolves relative paths against project root" , ( ) => {
41
+ it ( ' resolves relative paths against project root' , ( ) => {
42
42
expect (
43
- parseAbsolutePath ( { screenshotPath : " some/path.png" , projectRoot } )
44
- ) . toBe ( " /its/project/root/some/path.png" ) ;
43
+ parseAbsolutePath ( { screenshotPath : ' some/path.png' , projectRoot } ) ,
44
+ ) . toBe ( ' /its/project/root/some/path.png' ) ;
45
45
} ) ;
46
46
47
- it ( " builds proper win paths when found" , ( ) => {
47
+ it ( ' builds proper win paths when found' , ( ) => {
48
48
expect (
49
49
parseAbsolutePath ( {
50
50
screenshotPath : `${ PATH_VARIABLES . winSystemRootPath } /D/some/path.png` ,
51
51
projectRoot,
52
- } )
52
+ } ) ,
53
53
)
54
54
// that's expected output accorind to https://stackoverflow.com/a/64135721/8805801
55
- . toBe ( " D:\\/some/path.png" ) ;
55
+ . toBe ( ' D:\\/some/path.png' ) ;
56
56
} ) ;
57
57
58
- it ( " resolves relative paths against project root" , ( ) => {
58
+ it ( ' resolves relative paths against project root' , ( ) => {
59
59
expect (
60
60
parseAbsolutePath ( {
61
61
screenshotPath : `${ PATH_VARIABLES . unixSystemRootPath } /some/path.png` ,
62
62
projectRoot,
63
- } )
64
- ) . toBe ( " /some/path.png" ) ;
63
+ } ) ,
64
+ ) . toBe ( ' /some/path.png' ) ;
65
65
} ) ;
66
66
} ) ;
0 commit comments