Skip to content

Commit

Permalink
Run test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zzarcon committed Mar 28, 2019
1 parent 91becfc commit 684acf2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ cache: yarn
script:
- yarn
- yarn typecheck
- yarn test
notifications:
email: false
12 changes: 12 additions & 0 deletions __tests__/page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jest.mock('puppeteer');
import { PageProvider } from "../src/page";

describe('PageProvider', () => {
it('should return the same page instance', async () => {
const pageProvider = new PageProvider();
const pageA = await pageProvider.getPage();
const pageB = await pageProvider.getPage();

expect(pageA).toEqual(pageB);
})
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"build": "rm -rf dist && yarn build:es5 && yarn build:es2015",
"build:example": "rm -rf example/dist && tsc --project build/tsconfig.example.json",
"typecheck": "tsc --noEmit --project tsconfig.json",
"test": "jest"
"test": "jest -c ./build/jest.config.js"
},
"dependencies": {
"puppeteer": "^1.13.0",
"tslib": "^1.9.3"
},
"devDependencies": {
"@types/jest": "^24.0.11",
"@types/puppeteer": "^1.12.3",
"jest": "^24.5.0",
"ts-node-dev": "^1.0.0-pre.32",
Expand Down
3 changes: 1 addition & 2 deletions src/page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import puppeteer, { Browser } from 'puppeteer';
import { Page } from "puppeteer";
import puppeteer, { Browser, Page } from 'puppeteer';
import { DEBUG } from './config';

export class PageProvider {
Expand Down
28 changes: 6 additions & 22 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
{
"compilerOptions": {
"lib": ["dom", "es6"],
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"removeComments": true, /* Do not emit comments to output. */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"target": "es5",
"module": "commonjs",
"declaration": true,
"removeComments": true,
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true
}
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,18 @@
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.0.tgz#2cc2ca41051498382b43157c8227fea60363f94a"
integrity sha512-ohkhb9LehJy+PA40rDtGAji61NCgdtKLAlFoYp4cnuuQEswwdK3vz9SOIkkyc3wrk8dzjphQApNs56yyXLStaQ==

"@types/jest-diff@*":
version "20.0.1"
resolved "https://registry.yarnpkg.com/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"
integrity sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==

"@types/jest@^24.0.11":
version "24.0.11"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.11.tgz#1f099bea332c228ea6505a88159bfa86a5858340"
integrity sha512-2kLuPC5FDnWIDvaJBzsGTBQaBbnDweznicvK7UGYzlIJP4RJR2a4A/ByLUXEyEgag6jz8eHdlWExGDtH3EYUXQ==
dependencies:
"@types/jest-diff" "*"

"@types/node@*":
version "11.11.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.4.tgz#8808bd5a82bbf6f5d412eff1c228d178e7c24bb3"
Expand Down

0 comments on commit 684acf2

Please sign in to comment.