From 02e226b29da8bcbec6a97281c0857400723b8b73 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 26 Jan 2018 03:04:50 +0800 Subject: [PATCH] follow the latest puppeteer v1.0 api --- package.json | 2 +- test/puppeteer.spec.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d01c2df9..92643c92 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "test:linux": "npm run pretest && parallel ts-node -- ./src/**/*.spec.ts ./test/**/*.spec.ts && npm run posttest", "test:pack": "npm run dist && export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp test/fixture/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && node smoke-testing.js", "test:shell": "shellcheck bin/*.sh", - "test:unit": "blue-tape -r ts-node/register -r source-map-support/register \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"", + "test:unit": "blue-tape -r ts-node/register -r source-map-support/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"test/*.spec.ts\" \"tests/**/*.spec.ts\"", "test:win32": "npm run test:unit", "io-client": "ts-node bin/io-client", "demo": "ts-node example/ding-dong-bot.ts", diff --git a/test/puppeteer.spec.ts b/test/puppeteer.spec.ts index cd1ca40a..4fd526be 100755 --- a/test/puppeteer.spec.ts +++ b/test/puppeteer.spec.ts @@ -119,7 +119,7 @@ test('page.on(console)', async t => { const spy = sinon.spy() page.on('console', spy) - await (page.evaluate as any)((...args) => { + await page.evaluate((...args) => { console.log.apply(console, args) }, EXPECTED_ARG1, EXPECTED_ARG2) // , EXPECTED_ARG3) @@ -129,8 +129,8 @@ test('page.on(console)', async t => { t.ok(spy.calledOnce, 'should be called once') const consoleMessage = spy.firstCall.args[0] - t.equal(consoleMessage['type'], 'log', 'should get log type') - t.equal(consoleMessage['text'], EXPECTED_ARG1 + ' ' + EXPECTED_ARG2, 'should get console.log 1st/2nd arg') + t.equal(consoleMessage.type(), 'log', 'should get log type') + t.equal(consoleMessage.text(), EXPECTED_ARG1 + ' ' + EXPECTED_ARG2, 'should get console.log 1st/2nd arg') await page.close() await browser.close() @@ -190,8 +190,8 @@ test('other demos', async t => { // await page.setRequestInterception(true) page.on('request', interceptedRequest => { - if (interceptedRequest.url.endsWith('.png') - || interceptedRequest.url.endsWith('.jpg') + if (interceptedRequest.url().endsWith('.png') + || interceptedRequest.url().endsWith('.jpg') ) { interceptedRequest.abort() } else { -- GitLab