Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d499cf

Browse files
Merge pull request #126 from kobenguyent/feat/try-out-ts
feat: move to TS
2 parents 9fd7d14 + cacea7c commit 5d499cf

22 files changed

+15028
-728
lines changed

‎.github/workflows/npm-publish.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- master
1111

1212
jobs:
13+
1314
publish-npm:
1415
runs-on: ubuntu-latest
1516
steps:
@@ -19,6 +20,7 @@ jobs:
1920
node-version: 18
2021
registry-url: https://registry.npmjs.org/
2122
- run: npm i
23+
- run: npm run build
2224
- run: npx semantic-release
2325
env:
2426
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

‎.github/workflows/test.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Unit tests
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
node-version: [16.x, 18.x]
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- name: run unit tests
21+
run: |
22+
npm i
23+
npm test
24+
- name: Build
25+
run: |
26+
npm i
27+
npm run build
28+
- name: Run acceptance tests
29+
working-directory: ./__test__
30+
run: |
31+
npm i
32+
npm run test
33+
env:
34+
MAILINATOR_TOKEN: ${{secrets.MAILINATOR_TOKEN}}
35+
MAILINATOR_DOMAIN: ${{secrets.MAILINATOR_DOMAIN}}

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ typings/
6262

6363
#webstorm
6464
.idea
65+
dist
66+
coverage
67+
__test__/node_modules
68+
__test__/package-lock.json
69+
__test__/output

‎__test__/codecept.conf.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const config: CodeceptJS.MainConfig = {
2+
tests: './*_test.ts',
3+
output: './output',
4+
helpers: {
5+
Playwright: {
6+
url: 'https://codecept.io/',
7+
show: false,
8+
browser: 'chromium'
9+
},
10+
"ResembleHelper" : {
11+
"require": "../src/index",
12+
"baseFolder": "./screenshots/base/",
13+
"diffFolder": "./screenshots/diff/",
14+
"prepareBaseImage": false
15+
}
16+
},
17+
include: {
18+
I: './steps_file'
19+
},
20+
name: '__test__'
21+
}

‎__test__/index.spec.ts‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import ResembleHelper from "../src";
2+
const { container } = require('codeceptjs');
3+
const helpers = container.helpers();
4+
5+
let helper = new ResembleHelper({ baseFolder: './__test__/screenshots/base/',
6+
diffFolder: './__test__/screenshots/diff/',
7+
screenshotFolder: './__test__/output',
8+
prepareBaseImage: true })
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+
20+
describe('_getPrepareBaseImage()', () => {
21+
beforeAll(() => {
22+
helpers['Playwright'] = { hello: 1 }
23+
})
24+
test('should return false when no prepareBaseImage is provided', () => {
25+
expect(helper._getPrepareBaseImage({ prepareBaseImage: false, tolerance: 1 })).toBeFalsy()
26+
});
27+
28+
test('should return true when prepareBaseImage matched with config', () => {
29+
expect(helper._getPrepareBaseImage({ prepareBaseImage: true })).toBeTruthy()
30+
});
31+
})
32+
33+
describe('_getDiffImagePath()', () => {
34+
beforeAll(() => {
35+
helpers['Playwright'] = { hello: 1 }
36+
})
37+
test('should return diffImagePath', () => {
38+
expect(helper._getDiffImagePath('hello')).toContain('Diff_hello.png')
39+
});
40+
41+
})
42+
43+
describe('_getActualImagePath()', () => {
44+
beforeAll(() => {
45+
helpers['Playwright'] = { hello: 1 }
46+
})
47+
test('should return ActualImagePath', () => {
48+
expect(helper._getActualImagePath('hello')).toContain('hello')
49+
});
50+
51+
})
52+
53+
describe('_getBaseImagePath()', () => {
54+
beforeAll(() => {
55+
helpers['Playwright'] = { hello: 1 }
56+
})
57+
test('should return BaseImagePath', () => {
58+
expect(helper._getBaseImagePath('hello', {})).toContain('hello')
59+
});
60+
61+
})
62+
63+
describe('resolvePath()', () => {
64+
beforeAll(() => {
65+
helpers['Playwright'] = { hello: 1 }
66+
})
67+
test('should return resolvePath', () => {
68+
expect(helper.resolvePath('hello')).toContain('hello')
69+
});
70+
})

‎__test__/package.json‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "__test__",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "codeceptjs run --verbose"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"codeceptjs": "^3.4.1",
14+
"playwright": "^1.32.3"
15+
},
16+
"devDependencies": {
17+
"@types/node": "^18.15.11",
18+
"ts-node": "^10.9.1",
19+
"typescript": "^5.0.4"
20+
}
21+
}
121 KB
Loading[フレーム]
15.9 KB
Loading[フレーム]
121 KB
Loading[フレーム]
15.9 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /