From faebeb08ebf1d5b3cd867c6e3e0db28b4c5046d6 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Tue, 2 Apr 2019 21:38:52 +0800 Subject: [PATCH] update typescript and fix test cases --- package.json | 2 +- test/integration.test.ts | 12 +++++++++--- test/record.test.ts | 10 +++++++++- test/replayer.test.ts | 9 ++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d4051ea7..dd63b92d 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ts-node": "^7.0.1", "tslib": "^1.9.3", "tslint": "^4.5.1", - "typescript": "^3.2.4" + "typescript": "^3.4.1" }, "dependencies": { "@types/smoothscroll-polyfill": "^0.3.0", diff --git a/test/integration.test.ts b/test/integration.test.ts index 18332b42..8501e400 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -2,9 +2,15 @@ import * as fs from 'fs'; import * as path from 'path'; import * as puppeteer from 'puppeteer'; import { assertSnapshot } from './utils'; +import { Suite } from 'mocha'; -describe('record integration tests', () => { - function getHtml(fileName: string): string { +interface ISuite extends Suite { + code: string; + browser: puppeteer.Browser; +} + +describe('record integration tests', function(this: ISuite) { + const getHtml = (fileName: string): string => { const filePath = path.resolve(__dirname, `./html/${fileName}`); const html = fs.readFileSync(filePath, 'utf8'); return html.replace( @@ -24,7 +30,7 @@ describe('record integration tests', () => { `, ); - } + }; before(async () => { this.browser = await puppeteer.launch({ diff --git a/test/record.test.ts b/test/record.test.ts index 7f689598..ca56a6d0 100644 --- a/test/record.test.ts +++ b/test/record.test.ts @@ -11,6 +11,14 @@ import { EventType, } from '../src/types'; import { assertSnapshot } from './utils'; +import { Suite } from 'mocha'; + +interface ISuite extends Suite { + code: string; + browser: puppeteer.Browser; + page: puppeteer.Page; + events: eventWithTime[]; +} interface IWindow extends Window { rrweb: { @@ -19,7 +27,7 @@ interface IWindow extends Window { emit: (e: eventWithTime) => undefined; } -describe('record', () => { +describe('record', function(this: ISuite) { before(async () => { this.browser = await puppeteer.launch({ headless: false, diff --git a/test/replayer.test.ts b/test/replayer.test.ts index 52790e7f..ee591f4f 100644 --- a/test/replayer.test.ts +++ b/test/replayer.test.ts @@ -4,6 +4,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as puppeteer from 'puppeteer'; import { expect } from 'chai'; +import { Suite } from 'mocha'; import { EventType, eventWithTime, @@ -113,7 +114,13 @@ interface IWindow extends Window { }; } -describe('replayer', () => { +interface ISuite extends Suite { + code: string; + browser: puppeteer.Browser; + page: puppeteer.Page; +} + +describe('replayer', function(this: ISuite) { before(async () => { this.browser = await puppeteer.launch({ headless: false,