Skip to content

Commit

Permalink
Support headless chrome as a test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
liushooter committed Jun 4, 2020
1 parent 8d91b99 commit da401c1
Show file tree
Hide file tree
Showing 5 changed files with 849 additions and 27 deletions.
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ module.exports = {
'^.+\\.scss$': '<rootDir>/config/jest/cssTransform.js'
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
preset: "jest-puppeteer",
globals: {
window: {},
global:{},
}
};
2 changes: 2 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// require('expect-puppeteer')

const windowCrypto = require("window-crypto");
const crypto = require('crypto');

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@
"@material-ui/icons": "^4.9.1",
"@nervosnetwork/ckb-sdk-core": "^0.30.0",
"@nervosnetwork/ckb-sdk-utils": "^0.30.0",
"@types/expect-puppeteer": "^4.4.3",
"@types/jest-environment-puppeteer": "^4.3.1",
"@types/puppeteer": "^3.0.0",
"axios": "^0.19.2",
"blake2b": "^2.1.3",
"browser-passworder": "^2.0.3",
"dotenv-webpack": "^1.8.0",
"elliptic": "^6.5.2",
"formik": "^2.1.4",
"jest-puppeteer": "^4.4.0",
"keccak": "^3.0.0",
"moment": "^2.25.3",
"puppeteer": "^3.3.0",
"qrcode.react": "^1.0.0",
"query-string": "^6.12.1",
"react": "^16.13.0",
Expand Down
11 changes: 11 additions & 0 deletions src/test/headlessChrome.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'expect-puppeteer'

describe('test puppeteer', () => {
beforeAll(async () => {
await page.goto('https://so.com')
})

it('should display "360" text on so.com page', async () => {
await expect(page).toMatch('360')
})
})
Loading

0 comments on commit da401c1

Please sign in to comment.