-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests and update build generation
- Loading branch information
Showing
7 changed files
with
90 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "size" | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
size: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI_JOB_NUMBER: 1 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: | | ||
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* | ||
- uses: ./ | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,8 @@ | ||
name: "test" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
size: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI_JOB_NUMBER: 1 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: | | ||
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* | ||
- uses: ./ | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
// @ts-nocheck | ||
|
||
module.exports = { | ||
clearMocks: true, | ||
moduleFileExtensions: ['js', 'ts'], | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.ts'], | ||
testRunner: 'jest-circus/runner', | ||
moduleFileExtensions: ["js", "ts"], | ||
testEnvironment: "node", | ||
testMatch: ["**/*.spec.ts"], | ||
testRunner: "jest-circus/runner", | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
"^.+\\.ts$": "ts-jest" | ||
}, | ||
verbose: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import SizeLimit from "./SizeLimit"; | ||
|
||
describe("SizeLimit", () => { | ||
test("should parse size-limit output properly", () => { | ||
const limit = new SizeLimit(); | ||
const output = JSON.stringify([ | ||
{ | ||
name: "dist/index.js", | ||
passed: true, | ||
size: 110894, | ||
running: 0.10210999999999999, | ||
loading: 2.1658984375 | ||
} | ||
]); | ||
|
||
expect(limit.parseResults(output)).toEqual({ | ||
"dist/index.js": { | ||
loading: 2.1658984375, | ||
name: "dist/index.js", | ||
running: 0.10210999999999999, | ||
size: 110894, | ||
total: 2.2680084375000003 | ||
} | ||
}); | ||
}); | ||
|
||
test("should format size-limit results properly", () => { | ||
const limit = new SizeLimit(); | ||
const base = { | ||
"dist/index.js": { | ||
name: "dist/index.js", | ||
size: 110894, | ||
running: 0.10210999999999999, | ||
loading: 2.1658984375, | ||
total: 2.2680084375000003 | ||
} | ||
}; | ||
const current = { | ||
"dist/index.js": { | ||
name: "dist/index.js", | ||
size: 100894, | ||
running: 0.20210999999999999, | ||
loading: 2.5658984375, | ||
total: 2.7680084375000003 | ||
} | ||
}; | ||
|
||
expect(limit.formatResults(base, current)).toEqual([ | ||
[ | ||
"dist/index.js", | ||
"98.53 KB (-9.92% 🔽)", | ||
"2.6 s (+15.59% 🔺)", | ||
"203 ms (+49.48% 🔺)", | ||
"2.8 s" | ||
] | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters