Skip to content

Commit

Permalink
Test for changes in image output size (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilwanner committed Jul 23, 2020
1 parent 58e67c6 commit feb3c8c
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 224 deletions.
4 changes: 4 additions & 0 deletions .github/bundlewatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
},
{
"path": "./packages/*/lib/**/*.!(wasm)"
},
{
"path": "./packages/*/__tests__/out/**/*.*",
"compression": "none"
}
]
}
2 changes: 2 additions & 0 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm run test:sizes
- uses: cyrilwanner/bundlewatch-comment-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ lerna-debug.log*
# project
lib
tmp
out
target
211 changes: 0 additions & 211 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"build": "lerna run build --parallel",
"lint": "lerna run lint --parallel",
"test": "lerna run test --parallel",
"test:sizes": "lerna run test:sizes --parallel",
"postinstall": "lerna bootstrap",
"lerna": "lerna",
"bundlewatch": "bundlewatch --config .github/bundlewatch.json"
"lerna": "lerna"
},
"dependencies": {},
"devDependencies": {
Expand All @@ -18,7 +18,6 @@
"@types/jest": "^25.2.2",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"bundlewatch": "^0.2.7",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^6.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mozjpeg/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('mozjpeg', () => {
initTestUtils(__dirname);
});

afterAll(cleanup);
afterAll(() => cleanup());

// test all image sizes
['tiny', 'small', 'medium', 'large'].forEach((size) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/mozjpeg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lint": "tsc --noEmit && eslint . --ext .ts --ext .js",
"lint:fix": "npm run lint -- --fix",
"test": "jest",
"test:watch": "npm test -- --watch"
"test:watch": "npm test -- --watch",
"test:sizes": "KEEP_IMAGE_OUTPUT=true jest --testPathIgnorePatterns '.*performance.*'"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/oxipng/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('oxipng', () => {
initTestUtils(__dirname);
});

afterAll(cleanup);
afterAll(() => cleanup());

// test all image sizes
['tiny', 'small', 'medium', 'large'].forEach((size) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/oxipng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lint": "tsc --noEmit && eslint . --ext .ts --ext .js",
"lint:fix": "npm run lint -- --fix",
"test": "jest",
"test:watch": "npm test -- --watch"
"test:watch": "npm test -- --watch",
"test:sizes": "KEEP_IMAGE_OUTPUT=true jest --testPathIgnorePatterns '.*performance.*'"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
Expand Down
6 changes: 5 additions & 1 deletion packages/test-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ Initializes the test utils by configuring internal paths.
Path to the test root.
### `cleanup(): void`
### `cleanup(force?): void`
Cleans up tests by removing temporary files and directories.
##### `force?: boolean`
If true, will forcefully remove the tmp directory, even if the `KEEP_IMAGE_OUTPUT` env variable is set.
### `async getImage(fileName): { data: Buffer; info: OutputInfo }`
Loads an image file and returns its buffer and information.
Expand Down

0 comments on commit feb3c8c

Please sign in to comment.