Skip to content

Commit

Permalink
Centralize type assertions for better type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmccurdy committed Jan 19, 2023
1 parent b2f5208 commit 6f6930d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/__tests__/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import {
stringifyStep,
type Selector,
type Step,
type UserFlow,
} from '@puppeteer/replay'
import Extension, {formatAsJSLiteral, stringifySelector} from '../Extension'
import flow from './fixtures/example.json'
import flow from '../flow'

const extension = new Extension()
const selectors: Selector[] = [['aria/Test'], ['#test']]

describe('stringify', () => {
test('fixture', async () => {
expect(await stringify(flow as UserFlow, {extension})).toBe(
expect(await stringify(flow, {extension})).toBe(
await readFile(join(__dirname, 'fixtures/example.js'), 'utf8'),
)
})
Expand Down
7 changes: 3 additions & 4 deletions src/__tests__/RecorderPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {readFile} from 'fs/promises'
import {join} from 'path'
import type {Step, UserFlow} from '@puppeteer/replay'
import RecorderPlugin from '../RecorderPlugin'
import flow from './fixtures/example.json'
import flow from '../flow'

test('stringify', async () => {
expect(await new RecorderPlugin().stringify(flow as UserFlow)).toBe(
expect(await new RecorderPlugin().stringify(flow)).toBe(
await readFile(join(__dirname, 'fixtures/example.js'), 'utf8'),
)
})

test('stringifyStep', async () => {
expect(await new RecorderPlugin().stringifyStep(flow.steps[1] as Step)).toBe(
expect(await new RecorderPlugin().stringifyStep(flow.steps[1])).toBe(
"await waitFor(() => screen.getByText('More information...'))\n",
)
})
4 changes: 4 additions & 0 deletions src/flow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type {UserFlow} from '@puppeteer/replay'
import flow from './__tests__/fixtures/example.json'

export default flow as UserFlow

0 comments on commit 6f6930d

Please sign in to comment.