|  | 
|  | 1 | +import ResembleHelper from "../src"; | 
|  | 2 | +const { container } = require('codeceptjs'); | 
|  | 3 | +const helpers = container.helpers(); | 
|  | 4 | + | 
|  | 5 | +let helper = new ResembleHelper({baseFolder: 'string', | 
|  | 6 | + diffFolder: 'string', | 
|  | 7 | + screenshotFolder: 'string', | 
|  | 8 | + prepareBaseImage: 'string'}) | 
|  | 9 | + | 
|  | 10 | +describe('_getHelper()', () => { | 
|  | 11 | + test('should return error when no matching helper found', () => { | 
|  | 12 | + try { | 
|  | 13 | + helper._getHelper() | 
|  | 14 | + } catch (e: any) { | 
|  | 15 | + expect(e.message).toEqual('No matching helper found. Supported helpers: Playwright/Puppeteer/WebDriver/TestCafe/Appium') | 
|  | 16 | + } | 
|  | 17 | + }); | 
|  | 18 | + | 
|  | 19 | + test('should return matching helper', () => { | 
|  | 20 | + helpers['Playwright'] = { hello: 1 } | 
|  | 21 | + expect(helper._getHelper()).toEqual({ hello: 1 }) | 
|  | 22 | + }); | 
|  | 23 | +}) | 
|  | 24 | + | 
|  | 25 | + | 
|  | 26 | +describe('_getPrepareBaseImage()', () => { | 
|  | 27 | + beforeAll(() => { | 
|  | 28 | + helpers['Playwright'] = { hello: 1 } | 
|  | 29 | + }) | 
|  | 30 | + test('should return false when no prepareBaseImage is provided', () => { | 
|  | 31 | + expect(helper._getPrepareBaseImage({ hello: 1 })).toBeFalsy() | 
|  | 32 | + }); | 
|  | 33 | + | 
|  | 34 | + test('should return true when prepareBaseImage matched with config', () => { | 
|  | 35 | + expect(helper._getPrepareBaseImage({ prepareBaseImage: 'string' })).toBeTruthy() | 
|  | 36 | + }); | 
|  | 37 | +}) | 
|  | 38 | + | 
|  | 39 | +describe('_getDiffImagePath()', () => { | 
|  | 40 | + beforeAll(() => { | 
|  | 41 | + helpers['Playwright'] = { hello: 1 } | 
|  | 42 | + }) | 
|  | 43 | + test('should return diffImagePath', () => { | 
|  | 44 | + expect(helper._getDiffImagePath('hello')).toContain('Diff_hello.png') | 
|  | 45 | + }); | 
|  | 46 | + | 
|  | 47 | +}) | 
|  | 48 | + | 
|  | 49 | +describe('_getActualImagePath()', () => { | 
|  | 50 | + beforeAll(() => { | 
|  | 51 | + helpers['Playwright'] = { hello: 1 } | 
|  | 52 | + }) | 
|  | 53 | + test('should return ActualImagePath', () => { | 
|  | 54 | + expect(helper._getActualImagePath('hello')).toContain('hello') | 
|  | 55 | + }); | 
|  | 56 | + | 
|  | 57 | +}) | 
|  | 58 | + | 
|  | 59 | +describe('_getBaseImagePath()', () => { | 
|  | 60 | + beforeAll(() => { | 
|  | 61 | + helpers['Playwright'] = { hello: 1 } | 
|  | 62 | + }) | 
|  | 63 | + test('should return BaseImagePath', () => { | 
|  | 64 | + expect(helper._getBaseImagePath('hello', {})).toContain('hello') | 
|  | 65 | + }); | 
|  | 66 | + | 
|  | 67 | +}) | 
|  | 68 | + | 
|  | 69 | +describe('resolvePath()', () => { | 
|  | 70 | + beforeAll(() => { | 
|  | 71 | + helpers['Playwright'] = { hello: 1 } | 
|  | 72 | + }) | 
|  | 73 | + test('should return resolvePath', () => { | 
|  | 74 | + expect(helper.resolvePath('hello')).toContain('hello') | 
|  | 75 | + }); | 
|  | 76 | + | 
|  | 77 | +}) | 
0 commit comments