@smoothdeploy/playwright 1.57.1 → 1.58.1-beta-1770383926000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @smoothdeploy/playwright might be problematic. Click here for more details.
- package/ThirdPartyNotices.txt +1188 -65
- package/lib/agents/agentParser.js +89 -0
- package/lib/agents/generateAgents.js +27 -74
- package/lib/agents/generateAgents.js.map +7 -0
- package/lib/agents/playwright-test-planner.agent.md +1 -0
- package/lib/common/config.js +6 -4
- package/lib/common/config.js.map +7 -0
- package/lib/common/configLoader.js.map +7 -0
- package/lib/common/esmLoaderHost.js +2 -0
- package/lib/common/esmLoaderHost.js.map +7 -0
- package/lib/common/expectBundle.js +2 -17
- package/lib/common/expectBundle.js.map +7 -0
- package/lib/common/expectBundleImpl.js +132 -132
- package/lib/common/expectBundleImpl.js.map +7 -0
- package/lib/common/fixtures.js.map +7 -0
- package/lib/common/globals.js.map +7 -0
- package/lib/common/ipc.js.map +7 -0
- package/lib/common/poolBuilder.js.map +7 -0
- package/lib/common/process.js +28 -0
- package/lib/common/process.js.map +7 -0
- package/lib/common/suiteUtils.js.map +7 -0
- package/lib/common/test.js.map +7 -0
- package/lib/common/testLoader.js.map +7 -0
- package/lib/common/testType.js.map +7 -0
- package/lib/common/validators.js +10 -10
- package/lib/common/validators.js.map +7 -0
- package/lib/fsWatcher.js.map +7 -0
- package/lib/index.js +205 -12
- package/lib/index.js.map +7 -0
- package/lib/internalsForTest.js.map +7 -0
- package/lib/isomorphic/events.js.map +7 -0
- package/lib/isomorphic/folders.js.map +7 -0
- package/lib/isomorphic/stringInternPool.js.map +7 -0
- package/lib/isomorphic/teleReceiver.js +15 -2
- package/lib/isomorphic/teleReceiver.js.map +7 -0
- package/lib/isomorphic/teleSuiteUpdater.js +24 -4
- package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
- package/lib/isomorphic/testServerConnection.js.map +7 -0
- package/lib/isomorphic/testServerInterface.js.map +7 -0
- package/lib/isomorphic/testTree.js +13 -18
- package/lib/isomorphic/testTree.js.map +7 -0
- package/lib/isomorphic/types.d.js.map +7 -0
- package/lib/loader/loaderMain.js.map +7 -0
- package/lib/matchers/expect.js +2 -15
- package/lib/matchers/expect.js.map +7 -0
- package/lib/matchers/matcherHint.js +1 -44
- package/lib/matchers/matcherHint.js.map +7 -0
- package/lib/matchers/matchers.js +3 -2
- package/lib/matchers/matchers.js.map +7 -0
- package/lib/matchers/toBeTruthy.js +5 -3
- package/lib/matchers/toBeTruthy.js.map +7 -0
- package/lib/matchers/toEqual.js +4 -3
- package/lib/matchers/toEqual.js.map +7 -0
- package/lib/matchers/toHaveURL.js +5 -6
- package/lib/matchers/toHaveURL.js.map +7 -0
- package/lib/matchers/toMatchAriaSnapshot.js +5 -5
- package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
- package/lib/matchers/toMatchSnapshot.js +9 -8
- package/lib/matchers/toMatchSnapshot.js.map +7 -0
- package/lib/matchers/toMatchText.js +9 -9
- package/lib/matchers/toMatchText.js.map +7 -0
- package/lib/mcp/browser/actions.d.js.map +7 -0
- package/lib/mcp/browser/browserContextFactory.js +62 -29
- package/lib/mcp/browser/browserContextFactory.js.map +7 -0
- package/lib/mcp/browser/browserServerBackend.js +17 -9
- package/lib/mcp/browser/browserServerBackend.js.map +7 -0
- package/lib/mcp/browser/codegen.js.map +7 -0
- package/lib/mcp/browser/config.js +65 -12
- package/lib/mcp/browser/config.js.map +7 -0
- package/lib/mcp/browser/context.js +71 -94
- package/lib/mcp/browser/context.js.map +7 -0
- package/lib/mcp/browser/response.js +172 -131
- package/lib/mcp/browser/response.js.map +7 -0
- package/lib/mcp/browser/sessionLog.js +19 -104
- package/lib/mcp/browser/sessionLog.js.map +7 -0
- package/lib/mcp/browser/tab.js +92 -41
- package/lib/mcp/browser/tab.js.map +7 -0
- package/lib/mcp/browser/tools/common.js +8 -6
- package/lib/mcp/browser/tools/common.js.map +7 -0
- package/lib/mcp/browser/tools/console.js +7 -5
- package/lib/mcp/browser/tools/console.js.map +7 -0
- package/lib/mcp/browser/tools/dialogs.js +4 -4
- package/lib/mcp/browser/tools/dialogs.js.map +7 -0
- package/lib/mcp/browser/tools/evaluate.js +11 -19
- package/lib/mcp/browser/tools/evaluate.js.map +7 -0
- package/lib/mcp/browser/tools/files.js +3 -3
- package/lib/mcp/browser/tools/files.js.map +7 -0
- package/lib/mcp/browser/tools/form.js +9 -19
- package/lib/mcp/browser/tools/form.js.map +7 -0
- package/lib/mcp/browser/tools/install.js +6 -3
- package/lib/mcp/browser/tools/install.js.map +7 -0
- package/lib/mcp/browser/tools/keyboard.js +34 -11
- package/lib/mcp/browser/tools/keyboard.js.map +7 -0
- package/lib/mcp/browser/tools/mouse.js +11 -11
- package/lib/mcp/browser/tools/mouse.js.map +7 -0
- package/lib/mcp/browser/tools/navigate.js +14 -5
- package/lib/mcp/browser/tools/navigate.js.map +7 -0
- package/lib/mcp/browser/tools/network.js +20 -11
- package/lib/mcp/browser/tools/network.js.map +7 -0
- package/lib/mcp/browser/tools/open.js +57 -0
- package/lib/mcp/browser/tools/pdf.js +9 -19
- package/lib/mcp/browser/tools/pdf.js.map +7 -0
- package/lib/mcp/browser/tools/runCode.js +11 -8
- package/lib/mcp/browser/tools/runCode.js.map +7 -0
- package/lib/mcp/browser/tools/screenshot.js +16 -29
- package/lib/mcp/browser/tools/screenshot.js.map +7 -0
- package/lib/mcp/browser/tools/snapshot.js +21 -29
- package/lib/mcp/browser/tools/snapshot.js.map +7 -0
- package/lib/mcp/browser/tools/tabs.js +12 -12
- package/lib/mcp/browser/tools/tabs.js.map +7 -0
- package/lib/mcp/browser/tools/tool.js +2 -4
- package/lib/mcp/browser/tools/tool.js.map +7 -0
- package/lib/mcp/browser/tools/tracing.js +6 -6
- package/lib/mcp/browser/tools/tracing.js.map +7 -0
- package/lib/mcp/browser/tools/utils.js +49 -44
- package/lib/mcp/browser/tools/utils.js.map +7 -0
- package/lib/mcp/browser/tools/verify.js +24 -34
- package/lib/mcp/browser/tools/verify.js.map +7 -0
- package/lib/mcp/browser/tools/wait.js +6 -6
- package/lib/mcp/browser/tools/wait.js.map +7 -0
- package/lib/mcp/browser/tools.js +3 -1
- package/lib/mcp/browser/tools.js.map +7 -0
- package/lib/mcp/browser/watchdog.js.map +7 -0
- package/lib/mcp/config.d.js.map +7 -0
- package/lib/mcp/extension/cdpRelay.js +1 -1
- package/lib/mcp/extension/cdpRelay.js.map +7 -0
- package/lib/mcp/extension/extensionContextFactory.js +6 -5
- package/lib/mcp/extension/extensionContextFactory.js.map +7 -0
- package/lib/mcp/extension/protocol.js.map +7 -0
- package/lib/mcp/index.js.map +7 -0
- package/lib/mcp/log.js.map +7 -0
- package/lib/mcp/program.js +15 -20
- package/lib/mcp/program.js.map +7 -0
- package/lib/mcp/sdk/bundle.js.map +7 -0
- package/lib/mcp/sdk/exports.js +0 -2
- package/lib/mcp/sdk/exports.js.map +7 -0
- package/lib/mcp/sdk/http.js +20 -55
- package/lib/mcp/sdk/http.js.map +7 -0
- package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
- package/lib/mcp/sdk/proxyBackend.js.map +7 -0
- package/lib/mcp/sdk/server.js +29 -4
- package/lib/mcp/sdk/server.js.map +7 -0
- package/lib/mcp/sdk/tool.js +2 -2
- package/lib/mcp/sdk/tool.js.map +7 -0
- package/lib/mcp/terminal/cli.js +296 -0
- package/lib/mcp/terminal/command.js +56 -0
- package/lib/mcp/terminal/commands.js +333 -0
- package/lib/mcp/terminal/daemon.js +129 -0
- package/lib/mcp/terminal/help.json +32 -0
- package/lib/mcp/terminal/helpGenerator.js +88 -0
- package/lib/mcp/terminal/socketConnection.js +80 -0
- package/lib/mcp/test/browserBackend.js +3 -13
- package/lib/mcp/test/browserBackend.js.map +7 -0
- package/lib/mcp/test/generatorTools.js +9 -9
- package/lib/mcp/test/generatorTools.js.map +7 -0
- package/lib/mcp/test/plannerTools.js +23 -22
- package/lib/mcp/test/plannerTools.js.map +7 -0
- package/lib/mcp/test/seed.js.map +7 -0
- package/lib/mcp/test/streams.js.map +7 -0
- package/lib/mcp/test/testBackend.js +6 -6
- package/lib/mcp/test/testBackend.js.map +7 -0
- package/lib/mcp/test/testContext.js +9 -3
- package/lib/mcp/test/testContext.js.map +7 -0
- package/lib/mcp/test/testTool.js.map +7 -0
- package/lib/mcp/test/testTools.js +12 -10
- package/lib/mcp/test/testTools.js.map +7 -0
- package/lib/mcpBundleImpl.js.map +7 -0
- package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
- package/lib/plugins/index.js.map +7 -0
- package/lib/plugins/webServerPlugin.js.map +7 -0
- package/lib/program.js +18 -4
- package/lib/program.js.map +7 -0
- package/lib/reporters/base.js +29 -4
- package/lib/reporters/base.js.map +7 -0
- package/lib/reporters/blob.js +3 -0
- package/lib/reporters/blob.js.map +7 -0
- package/lib/reporters/dot.js +17 -0
- package/lib/reporters/dot.js.map +7 -0
- package/lib/reporters/empty.js.map +7 -0
- package/lib/reporters/github.js.map +7 -0
- package/lib/reporters/html.js +13 -3
- package/lib/reporters/html.js.map +7 -0
- package/lib/reporters/internalReporter.js +6 -0
- package/lib/reporters/internalReporter.js.map +7 -0
- package/lib/reporters/json.js.map +7 -0
- package/lib/reporters/junit.js.map +7 -0
- package/lib/reporters/line.js +18 -0
- package/lib/reporters/line.js.map +7 -0
- package/lib/reporters/list.js +22 -0
- package/lib/reporters/list.js.map +7 -0
- package/lib/reporters/listModeReporter.js.map +7 -0
- package/lib/reporters/markdown.js.map +7 -0
- package/lib/reporters/merge.js +25 -8
- package/lib/reporters/merge.js.map +7 -0
- package/lib/reporters/multiplexer.js +8 -0
- package/lib/reporters/multiplexer.js.map +7 -0
- package/lib/reporters/reporterV2.js.map +7 -0
- package/lib/reporters/smoothdeploy.js +191 -0
- package/lib/reporters/teleEmitter.js +22 -4
- package/lib/reporters/teleEmitter.js.map +7 -0
- package/lib/reporters/versions/blobV1.js.map +7 -0
- package/lib/runner/dispatcher.js +20 -4
- package/lib/runner/dispatcher.js.map +7 -0
- package/lib/runner/failureTracker.js.map +7 -0
- package/lib/runner/lastRun.js.map +7 -0
- package/lib/runner/loadUtils.js +2 -2
- package/lib/runner/loadUtils.js.map +7 -0
- package/lib/runner/loaderHost.js.map +7 -0
- package/lib/runner/processHost.js +19 -0
- package/lib/runner/processHost.js.map +7 -0
- package/lib/runner/projectUtils.js +1 -1
- package/lib/runner/projectUtils.js.map +7 -0
- package/lib/runner/rebase.js.map +7 -0
- package/lib/runner/reporters.js +3 -1
- package/lib/runner/reporters.js.map +7 -0
- package/lib/runner/sigIntWatcher.js.map +7 -0
- package/lib/runner/storage.js +91 -0
- package/lib/runner/taskRunner.js.map +7 -0
- package/lib/runner/tasks.js.map +7 -0
- package/lib/runner/testGroups.js +14 -6
- package/lib/runner/testGroups.js.map +7 -0
- package/lib/runner/testRunner.js +13 -4
- package/lib/runner/testRunner.js.map +7 -0
- package/lib/runner/testServer.js +2 -2
- package/lib/runner/testServer.js.map +7 -0
- package/lib/runner/uiModeReporter.js.map +7 -0
- package/lib/runner/vcs.js.map +7 -0
- package/lib/runner/watchMode.js +2 -1
- package/lib/runner/watchMode.js.map +7 -0
- package/lib/runner/workerHost.js +6 -0
- package/lib/runner/workerHost.js.map +7 -0
- package/lib/third_party/pirates.js.map +7 -0
- package/lib/third_party/tsconfig-loader.js.map +7 -0
- package/lib/transform/babelBundle.js +3 -0
- package/lib/transform/babelBundle.js.map +7 -0
- package/lib/transform/babelBundleImpl.js +134 -134
- package/lib/transform/babelBundleImpl.js.map +7 -0
- package/lib/transform/compilationCache.js +2 -0
- package/lib/transform/compilationCache.js.map +7 -0
- package/lib/transform/esmLoader.js +10 -11
- package/lib/transform/esmLoader.js.map +7 -0
- package/lib/transform/md.js +221 -0
- package/lib/transform/portTransport.js.map +7 -0
- package/lib/transform/transform.js +18 -8
- package/lib/transform/transform.js.map +7 -0
- package/lib/util.js +3 -6
- package/lib/util.js.map +7 -0
- package/lib/utilsBundle.js +7 -0
- package/lib/utilsBundle.js.map +7 -0
- package/lib/utilsBundleImpl.js +51 -48
- package/lib/utilsBundleImpl.js.map +7 -0
- package/lib/worker/fixtureRunner.js +6 -2
- package/lib/worker/fixtureRunner.js.map +7 -0
- package/lib/worker/testInfo.js +39 -19
- package/lib/worker/testInfo.js.map +7 -0
- package/lib/worker/testTracing.js.map +7 -0
- package/lib/worker/timeoutManager.js.map +7 -0
- package/lib/worker/util.js.map +7 -0
- package/lib/worker/workerMain.js +17 -16
- package/lib/worker/workerMain.js.map +7 -0
- package/package.json +2 -2
- package/test.mjs +1 -0
- package/types/test.d.ts +26 -6
- package/types/testReporter.d.ts +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/matchers.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asLocatorDescription, constructURLBasedOnBaseURL, isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils';\nimport { colors } from 'playwright-core/lib/utils';\n\nimport { expectTypes } from '../util';\nimport { toBeTruthy } from './toBeTruthy';\nimport { toEqual } from './toEqual';\nimport { toHaveURLWithPredicate } from './toHaveURL';\nimport { toMatchText } from './toMatchText';\nimport { toHaveScreenshotStepTitle } from './toMatchSnapshot';\nimport { takeFirst } from '../common/config';\nimport { currentTestInfo } from '../common/globals';\nimport { TestInfoImpl } from '../worker/testInfo';\nimport { formatMatcherMessage } from './matcherHint';\n\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { TestStepInfoImpl } from '../worker/testInfo';\nimport type { APIResponse, Locator, Frame, Page } from 'playwright-core';\nimport type { FrameExpectParams } from 'playwright-core/lib/client/types';\n\nexport type ExpectMatcherStateInternal = ExpectMatcherState & { _stepInfo?: TestStepInfoImpl };\n\nexport interface LocatorEx extends Locator {\n _selector: string;\n _expect(expression: string, options: FrameExpectParams): Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean, errorMessage?: string }>;\n}\n\nexport interface FrameEx extends Frame {\n _expect(expression: string, options: FrameExpectParams): Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean, errorMessage?: string }>;\n}\n\ninterface APIResponseEx extends APIResponse {\n _fetchLog(): Promise<string[]>;\n}\n\nexport function toBeAttached(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { attached?: boolean, timeout?: number },\n) {\n const attached = !options || options.attached === undefined || options.attached;\n const expected = attached ? 'attached' : 'detached';\n const arg = attached ? '' : '{ attached: false }';\n return toBeTruthy.call(this, 'toBeAttached', locator, 'Locator', expected, arg, async (isNot, timeout) => {\n return await locator._expect(attached ? 'to.be.attached' : 'to.be.detached', { isNot, timeout });\n }, options);\n}\n\nexport function toBeChecked(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { checked?: boolean, indeterminate?: boolean, timeout?: number },\n) {\n const checked = options?.checked;\n const indeterminate = options?.indeterminate;\n const expectedValue = {\n checked,\n indeterminate,\n };\n let expected: string;\n let arg: string;\n if (options?.indeterminate) {\n expected = 'indeterminate';\n arg = `{ indeterminate: true }`;\n } else {\n expected = options?.checked === false ? 'unchecked' : 'checked';\n arg = options?.checked === false ? `{ checked: false }` : '';\n }\n return toBeTruthy.call(this, 'toBeChecked', locator, 'Locator', expected, arg, async (isNot, timeout) => {\n return await locator._expect('to.be.checked', { isNot, timeout, expectedValue });\n }, options);\n}\n\nexport function toBeDisabled(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { timeout?: number },\n) {\n return toBeTruthy.call(this, 'toBeDisabled', locator, 'Locator', 'disabled', '', async (isNot, timeout) => {\n return await locator._expect('to.be.disabled', { isNot, timeout });\n }, options);\n}\n\nexport function toBeEditable(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { editable?: boolean, timeout?: number },\n) {\n const editable = !options || options.editable === undefined || options.editable;\n const expected = editable ? 'editable' : 'readOnly';\n const arg = editable ? '' : '{ editable: false }';\n return toBeTruthy.call(this, 'toBeEditable', locator, 'Locator', expected, arg, async (isNot, timeout) => {\n return await locator._expect(editable ? 'to.be.editable' : 'to.be.readonly', { isNot, timeout });\n }, options);\n}\n\nexport function toBeEmpty(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { timeout?: number },\n) {\n return toBeTruthy.call(this, 'toBeEmpty', locator, 'Locator', 'empty', '', async (isNot, timeout) => {\n return await locator._expect('to.be.empty', { isNot, timeout });\n }, options);\n}\n\nexport function toBeEnabled(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { enabled?: boolean, timeout?: number },\n) {\n const enabled = !options || options.enabled === undefined || options.enabled;\n const expected = enabled ? 'enabled' : 'disabled';\n const arg = enabled ? '' : '{ enabled: false }';\n return toBeTruthy.call(this, 'toBeEnabled', locator, 'Locator', expected, arg, async (isNot, timeout) => {\n return await locator._expect(enabled ? 'to.be.enabled' : 'to.be.disabled', { isNot, timeout });\n }, options);\n}\n\nexport function toBeFocused(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { timeout?: number },\n) {\n return toBeTruthy.call(this, 'toBeFocused', locator, 'Locator', 'focused', '', async (isNot, timeout) => {\n return await locator._expect('to.be.focused', { isNot, timeout });\n }, options);\n}\n\nexport function toBeHidden(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { timeout?: number },\n) {\n return toBeTruthy.call(this, 'toBeHidden', locator, 'Locator', 'hidden', '', async (isNot, timeout) => {\n return await locator._expect('to.be.hidden', { isNot, timeout });\n }, options);\n}\n\nexport function toBeVisible(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { visible?: boolean, timeout?: number },\n) {\n const visible = !options || options.visible === undefined || options.visible;\n const expected = visible ? 'visible' : 'hidden';\n const arg = visible ? '' : '{ visible: false }';\n return toBeTruthy.call(this, 'toBeVisible', locator, 'Locator', expected, arg, async (isNot, timeout) => {\n return await locator._expect(visible ? 'to.be.visible' : 'to.be.hidden', { isNot, timeout });\n }, options);\n}\n\nexport function toBeInViewport(\n this: ExpectMatcherState,\n locator: LocatorEx,\n options?: { timeout?: number, ratio?: number },\n) {\n return toBeTruthy.call(this, 'toBeInViewport', locator, 'Locator', 'in viewport', '', async (isNot, timeout) => {\n return await locator._expect('to.be.in.viewport', { isNot, expectedNumber: options?.ratio, timeout });\n }, options);\n}\n\nexport function toContainText(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp | (string | RegExp)[],\n options: { timeout?: number, useInnerText?: boolean, ignoreCase?: boolean } = {},\n) {\n if (Array.isArray(expected)) {\n return toEqual.call(this, 'toContainText', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });\n return await locator._expect('to.contain.text.array', { expectedText, isNot, useInnerText: options.useInnerText, timeout });\n }, expected, { ...options, contains: true });\n } else {\n return toMatchText.call(this, 'toContainText', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });\n return await locator._expect('to.have.text', { expectedText, isNot, useInnerText: options.useInnerText, timeout });\n }, expected, { ...options, matchSubstring: true });\n }\n}\n\nexport function toHaveAccessibleDescription(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp,\n options?: { timeout?: number, ignoreCase?: boolean },\n) {\n return toMatchText.call(this, 'toHaveAccessibleDescription', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });\n return await locator._expect('to.have.accessible.description', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveAccessibleName(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp,\n options?: { timeout?: number, ignoreCase?: boolean },\n) {\n return toMatchText.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });\n return await locator._expect('to.have.accessible.name', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveAccessibleErrorMessage(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp,\n options?: { timeout?: number; ignoreCase?: boolean },\n) {\n return toMatchText.call(this, 'toHaveAccessibleErrorMessage', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });\n return await locator._expect('to.have.accessible.error.message', { expectedText: expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveAttribute(\n this: ExpectMatcherState,\n locator: LocatorEx,\n name: string,\n expected: string | RegExp | undefined | { timeout?: number },\n options?: { timeout?: number, ignoreCase?: boolean },\n) {\n if (!options) {\n // Update params for the case toHaveAttribute(name, options);\n if (typeof expected === 'object' && !isRegExp(expected)) {\n options = expected;\n expected = undefined;\n }\n }\n if (expected === undefined) {\n return toBeTruthy.call(this, 'toHaveAttribute', locator, 'Locator', 'have attribute', '', async (isNot, timeout) => {\n return await locator._expect('to.have.attribute', { expressionArg: name, isNot, timeout });\n }, options);\n }\n return toMatchText.call(this, 'toHaveAttribute', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected as (string | RegExp)], { ignoreCase: options?.ignoreCase });\n return await locator._expect('to.have.attribute.value', { expressionArg: name, expectedText, isNot, timeout });\n }, expected as (string | RegExp), options);\n}\n\nexport function toHaveClass(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp | (string | RegExp)[],\n options?: { timeout?: number },\n) {\n if (Array.isArray(expected)) {\n return toEqual.call(this, 'toHaveClass', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues(expected);\n return await locator._expect('to.have.class.array', { expectedText, isNot, timeout });\n }, expected, options);\n } else {\n return toMatchText.call(this, 'toHaveClass', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected]);\n return await locator._expect('to.have.class', { expectedText, isNot, timeout });\n }, expected, options);\n }\n}\n\nexport function toContainClass(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | string[],\n options?: { timeout?: number },\n) {\n if (Array.isArray(expected)) {\n if (expected.some(e => isRegExp(e)))\n throw new Error(`\"expected\" argument in toContainClass cannot contain RegExp values`);\n return toEqual.call(this, 'toContainClass', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues(expected);\n return await locator._expect('to.contain.class.array', { expectedText, isNot, timeout });\n }, expected, options);\n } else {\n if (isRegExp(expected))\n throw new Error(`\"expected\" argument in toContainClass cannot be a RegExp value`);\n return toMatchText.call(this, 'toContainClass', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected]);\n return await locator._expect('to.contain.class', { expectedText, isNot, timeout });\n }, expected, options);\n }\n}\n\nexport function toHaveCount(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: number,\n options?: { timeout?: number },\n) {\n return toEqual.call(this, 'toHaveCount', locator, 'Locator', async (isNot, timeout) => {\n return await locator._expect('to.have.count', { expectedNumber: expected, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveCSS(\n this: ExpectMatcherState,\n locator: LocatorEx,\n name: string,\n expected: string | RegExp,\n options?: { timeout?: number },\n) {\n return toMatchText.call(this, 'toHaveCSS', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected]);\n return await locator._expect('to.have.css', { expressionArg: name, expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveId(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp,\n options?: { timeout?: number },\n) {\n return toMatchText.call(this, 'toHaveId', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected]);\n return await locator._expect('to.have.id', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveJSProperty(\n this: ExpectMatcherState,\n locator: LocatorEx,\n name: string,\n expected: any,\n options?: { timeout?: number },\n) {\n return toEqual.call(this, 'toHaveJSProperty', locator, 'Locator', async (isNot, timeout) => {\n return await locator._expect('to.have.property', { expressionArg: name, expectedValue: expected, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveRole(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string,\n options?: { timeout?: number, ignoreCase?: boolean },\n) {\n if (!isString(expected))\n throw new Error(`\"role\" argument in toHaveRole must be a string`);\n return toMatchText.call(this, 'toHaveRole', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected]);\n return await locator._expect('to.have.role', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveText(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp | (string | RegExp)[],\n options: { timeout?: number, useInnerText?: boolean, ignoreCase?: boolean } = {},\n) {\n if (Array.isArray(expected)) {\n return toEqual.call(this, 'toHaveText', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });\n return await locator._expect('to.have.text.array', { expectedText, isNot, useInnerText: options?.useInnerText, timeout });\n }, expected, options);\n } else {\n return toMatchText.call(this, 'toHaveText', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });\n return await locator._expect('to.have.text', { expectedText, isNot, useInnerText: options?.useInnerText, timeout });\n }, expected, options);\n }\n}\n\nexport function toHaveValue(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: string | RegExp,\n options?: { timeout?: number },\n) {\n return toMatchText.call(this, 'toHaveValue', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected]);\n return await locator._expect('to.have.value', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveValues(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expected: (string | RegExp)[],\n options?: { timeout?: number },\n) {\n return toEqual.call(this, 'toHaveValues', locator, 'Locator', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues(expected);\n return await locator._expect('to.have.values', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveTitle(\n this: ExpectMatcherState,\n page: Page,\n expected: string | RegExp,\n options: { timeout?: number } = {},\n) {\n return toMatchText.call(this, 'toHaveTitle', page, 'Page', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { normalizeWhiteSpace: true });\n return await (page.mainFrame() as FrameEx)._expect('to.have.title', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport function toHaveURL(\n this: ExpectMatcherState,\n page: Page,\n expected: string | RegExp | ((url: URL) => boolean),\n options?: { ignoreCase?: boolean; timeout?: number },\n) {\n // Ports don't support predicates. Keep separate server and client codepaths\n if (typeof expected === 'function')\n return toHaveURLWithPredicate.call(this, page, expected, options);\n\n const baseURL = (page.context() as any)._options.baseURL;\n expected = typeof expected === 'string' ? constructURLBasedOnBaseURL(baseURL, expected) : expected;\n return toMatchText.call(this, 'toHaveURL', page, 'Page', async (isNot, timeout) => {\n const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase });\n return await (page.mainFrame() as FrameEx)._expect('to.have.url', { expectedText, isNot, timeout });\n }, expected, options);\n}\n\nexport async function toBeOK(\n this: ExpectMatcherState,\n response: APIResponseEx\n) {\n const matcherName = 'toBeOK';\n expectTypes(response, ['APIResponse'], matcherName);\n\n const contentType = response.headers()['content-type'];\n const isTextEncoding = contentType && isTextualMimeType(contentType);\n const [log, text] = (this.isNot === response.ok()) ? await Promise.all([\n response._fetchLog(),\n isTextEncoding ? response.text() : null\n ]) : [];\n\n const message = () => formatMatcherMessage(this, {\n matcherName,\n receiver: 'response',\n expectation: '',\n log,\n }) + (text === null ? '' : `\\nResponse text:\\n${colors.dim(text?.substring(0, 1000) || '')}`);\n\n const pass = response.ok();\n return { message, pass };\n}\n\nexport async function toPass(\n this: ExpectMatcherState,\n callback: () => any,\n options: {\n intervals?: number[];\n timeout?: number,\n } = {},\n) {\n const testInfo = currentTestInfo();\n const timeout = takeFirst(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);\n const intervals = takeFirst(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1000]);\n\n const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : TestInfoImpl._defaultDeadlineForMatcher(timeout);\n const result = await pollAgainstDeadline<Error|undefined>(async () => {\n if (testInfo && currentTestInfo() !== testInfo)\n return { continuePolling: false, result: undefined };\n try {\n await callback();\n return { continuePolling: !!this.isNot, result: undefined };\n } catch (e) {\n return { continuePolling: !this.isNot, result: e };\n }\n }, deadline, intervals);\n\n if (result.timedOut) {\n const message = result.result ? [\n result.result.message,\n '',\n `Call Log:`,\n `- ${timeoutMessage}`,\n ].join('\\n') : timeoutMessage;\n return { message: () => message, pass: !!this.isNot };\n }\n return { pass: !this.isNot, message: () => '' };\n}\n\nexport function computeMatcherTitleSuffix(matcherName: string, receiver: any, args: any[]): { short?: string, long?: string } {\n if (matcherName === 'toHaveScreenshot') {\n const title = toHaveScreenshotStepTitle(...args);\n return { short: title ? `(${title})` : '' };\n }\n if (receiver && typeof receiver === 'object' && receiver.constructor?.name === 'Locator') {\n try {\n return { long: ' ' + asLocatorDescription('javascript', (receiver as LocatorEx)._selector) };\n } catch {\n }\n }\n return {};\n}\n"],
|
|
5
|
+
"mappings": ";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kCAAqC,YAAY;AACpE,QAAI,gBAAY,gCAAgB,MAAM;AACpC,aAAO,EAAE,iBAAiB,OAAO,QAAQ,OAAU;AACrD,QAAI;AACF,YAAM,SAAS;AACf,aAAO,EAAE,iBAAiB,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAU;AAAA,IAC5D,SAAS,GAAG;AACV,aAAO,EAAE,iBAAiB,CAAC,KAAK,OAAO,QAAQ,EAAE;AAAA,IACnD;AAAA,EACF,GAAG,UAAU,SAAS;AAEtB,MAAI,OAAO,UAAU;AACnB,UAAM,UAAU,OAAO,SAAS;AAAA,MAC9B,OAAO,OAAO;AAAA,MACd;AAAA,MACA;AAAA,MACA,KAAK,cAAc;AAAA,IACrB,EAAE,KAAK,IAAI,IAAI;AACf,WAAO,EAAE,SAAS,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK,MAAM;AAAA,EACtD;AACA,SAAO,EAAE,MAAM,CAAC,KAAK,OAAO,SAAS,MAAM,GAAG;AAChD;AAEO,SAAS,0BAA0B,aAAqB,UAAe,MAAgD;AAC5H,MAAI,gBAAgB,oBAAoB;AACtC,UAAM,YAAQ,kDAA0B,GAAG,IAAI;AAC/C,WAAO,EAAE,OAAO,QAAQ,IAAI,KAAK,MAAM,GAAG;AAAA,EAC5C;AACA,MAAI,YAAY,OAAO,aAAa,YAAY,SAAS,aAAa,SAAS,WAAW;AACxF,QAAI;AACF,aAAO,EAAE,MAAM,UAAM,mCAAqB,cAAe,SAAuB,SAAS,EAAE;AAAA,IAC7F,QAAQ;AAAA,IACR;AAAA,EACF;AACA,SAAO,CAAC;AACV;",
|
|
6
|
+
"names": ["import_utils"]
|
|
7
|
+
}
|
|
@@ -21,8 +21,8 @@ __export(toBeTruthy_exports, {
|
|
|
21
21
|
toBeTruthy: () => toBeTruthy
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(toBeTruthy_exports);
|
|
24
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
24
25
|
var import_util = require("../util");
|
|
25
|
-
var import_matcherHint = require("./matcherHint");
|
|
26
26
|
async function toBeTruthy(matcherName, locator, receiverType, expected, arg, query, options = {}) {
|
|
27
27
|
(0, import_util.expectTypes)(locator, [receiverType], matcherName);
|
|
28
28
|
const timeout = options.timeout ?? this.timeout;
|
|
@@ -45,10 +45,12 @@ async function toBeTruthy(matcherName, locator, receiverType, expected, arg, que
|
|
|
45
45
|
printedReceived = errorMessage ? "" : `Received: ${received}`;
|
|
46
46
|
}
|
|
47
47
|
const message = () => {
|
|
48
|
-
return (0,
|
|
48
|
+
return (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
49
|
+
isNot: this.isNot,
|
|
50
|
+
promise: this.promise,
|
|
49
51
|
matcherName,
|
|
50
52
|
expectation: arg,
|
|
51
|
-
locator,
|
|
53
|
+
locator: locator.toString(),
|
|
52
54
|
timeout,
|
|
53
55
|
timedOut,
|
|
54
56
|
printedExpected,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/toBeTruthy.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { expectTypes } from '../util';\nimport { formatMatcherMessage } from './matcherHint';\n\nimport type { MatcherResult } from './matcherHint';\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { Locator } from 'playwright-core';\n\nexport async function toBeTruthy(\n this: ExpectMatcherState,\n matcherName: string,\n locator: Locator,\n receiverType: string,\n expected: string,\n arg: string,\n query: (isNot: boolean, timeout: number) => Promise<{ matches: boolean, log?: string[], received?: any, timedOut?: boolean, errorMessage?: string }>,\n options: { timeout?: number } = {},\n): Promise<MatcherResult<any, any>> {\n expectTypes(locator, [receiverType], matcherName);\n\n const timeout = options.timeout ?? this.timeout;\n\n const { matches: pass, log, timedOut, received, errorMessage } = await query(!!this.isNot, timeout);\n\n if (pass === !this.isNot) {\n return {\n name: matcherName,\n message: () => '',\n pass,\n expected\n };\n }\n\n let printedReceived: string | undefined;\n let printedExpected: string | undefined;\n if (pass) {\n printedExpected = `Expected: not ${expected}`;\n printedReceived = errorMessage ? '' : `Received: ${expected}`;\n } else {\n printedExpected = `Expected: ${expected}`;\n printedReceived = errorMessage ? '' : `Received: ${received}`;\n }\n const message = () => {\n return formatMatcherMessage(this, {\n matcherName,\n expectation: arg,\n locator,\n timeout,\n timedOut,\n printedExpected,\n printedReceived,\n errorMessage,\n log,\n });\n };\n\n return {\n message,\n pass,\n actual: received,\n name: matcherName,\n expected,\n log,\n timeout: timedOut ? timeout : undefined,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,kBAA4B;AAC5B,yBAAqC;AAMrC,eAAsB,WAEpB,aACA,SACA,cACA,UACA,KACA,OACA,UAAgC,CAAC,GACC;AAClC,+BAAY,SAAS,CAAC,YAAY,GAAG,WAAW;AAEhD,QAAM,UAAU,QAAQ,WAAW,KAAK;AAExC,QAAM,EAAE,SAAS,MAAM,KAAK,UAAU,UAAU,aAAa,IAAI,MAAM,MAAM,CAAC,CAAC,KAAK,OAAO,OAAO;AAElG,MAAI,SAAS,CAAC,KAAK,OAAO;AACxB,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,MAAM;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACJ,MAAI;AACJ,MAAI,MAAM;AACR,sBAAkB,iBAAiB,QAAQ;AAC3C,sBAAkB,eAAe,KAAK,aAAa,QAAQ;AAAA,EAC7D,OAAO;AACL,sBAAkB,aAAa,QAAQ;AACvC,sBAAkB,eAAe,KAAK,aAAa,QAAQ;AAAA,EAC7D;AACA,QAAM,UAAU,MAAM;AACpB,eAAO,yCAAqB,MAAM;AAAA,MAChC;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,SAAS,WAAW,UAAU;AAAA,EAChC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/matchers/toEqual.js
CHANGED
|
@@ -23,7 +23,6 @@ __export(toEqual_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(toEqual_exports);
|
|
24
24
|
var import_utils = require("playwright-core/lib/utils");
|
|
25
25
|
var import_util = require("../util");
|
|
26
|
-
var import_matcherHint = require("./matcherHint");
|
|
27
26
|
const EXPECTED_LABEL = "Expected";
|
|
28
27
|
const RECEIVED_LABEL = "Received";
|
|
29
28
|
async function toEqual(matcherName, locator, receiverType, query, expected, options = {}) {
|
|
@@ -70,10 +69,12 @@ async function toEqual(matcherName, locator, receiverType, query, expected, opti
|
|
|
70
69
|
);
|
|
71
70
|
}
|
|
72
71
|
const message = () => {
|
|
73
|
-
return (0,
|
|
72
|
+
return (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
73
|
+
isNot: this.isNot,
|
|
74
|
+
promise: this.promise,
|
|
74
75
|
matcherName,
|
|
75
76
|
expectation: "expected",
|
|
76
|
-
locator,
|
|
77
|
+
locator: locator.toString(),
|
|
77
78
|
timeout,
|
|
78
79
|
timedOut,
|
|
79
80
|
printedExpected,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/toEqual.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isRegExp } from 'playwright-core/lib/utils';\n\nimport { expectTypes } from '../util';\nimport { formatMatcherMessage } from './matcherHint';\n\nimport type { MatcherResult } from './matcherHint';\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { Locator } from 'playwright-core';\n\n// Omit colon and one or more spaces, so can call getLabelPrinter.\nconst EXPECTED_LABEL = 'Expected';\nconst RECEIVED_LABEL = 'Received';\n\nexport async function toEqual<T>(\n this: ExpectMatcherState,\n matcherName: string,\n locator: Locator,\n receiverType: string,\n query: (isNot: boolean, timeout: number) => Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean, errorMessage?: string }>,\n expected: T,\n options: { timeout?: number, contains?: boolean } = {},\n): Promise<MatcherResult<any, any>> {\n expectTypes(locator, [receiverType], matcherName);\n\n const timeout = options.timeout ?? this.timeout;\n\n const { matches: pass, received, log, timedOut, errorMessage } = await query(!!this.isNot, timeout);\n\n if (pass === !this.isNot) {\n return {\n name: matcherName,\n message: () => '',\n pass,\n expected\n };\n }\n\n let printedReceived: string | undefined;\n let printedExpected: string | undefined;\n let printedDiff: string | undefined;\n if (pass) {\n printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;\n printedReceived = errorMessage ? '' : `Received: ${this.utils.printReceived(received)}`;\n } else if (errorMessage) {\n printedExpected = `Expected: ${this.utils.printExpected(expected)}`;\n } else if (Array.isArray(expected) && Array.isArray(received)) {\n const normalizedExpected = expected.map((exp, index) => {\n const rec = received[index];\n if (isRegExp(exp))\n return exp.test(rec) ? rec : exp;\n\n return exp;\n });\n printedDiff = this.utils.printDiffOrStringify(\n normalizedExpected,\n received,\n EXPECTED_LABEL,\n RECEIVED_LABEL,\n false,\n );\n } else {\n printedDiff = this.utils.printDiffOrStringify(\n expected,\n received,\n EXPECTED_LABEL,\n RECEIVED_LABEL,\n false,\n );\n }\n const message = () => {\n return formatMatcherMessage(this, {\n matcherName,\n expectation: 'expected',\n locator,\n timeout,\n timedOut,\n printedExpected,\n printedReceived,\n printedDiff,\n errorMessage,\n log,\n });\n };\n\n // Passing the actual and expected objects so that a custom reporter\n // could access them, for example in order to display a custom visual diff,\n // or create a different error message\n return {\n actual: received,\n expected, message,\n name: matcherName,\n pass,\n log,\n timeout: timedOut ? timeout : undefined,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,mBAAyB;AAEzB,kBAA4B;AAC5B,yBAAqC;AAOrC,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAEvB,eAAsB,QAEpB,aACA,SACA,cACA,OACA,UACA,UAAoD,CAAC,GACnB;AAClC,+BAAY,SAAS,CAAC,YAAY,GAAG,WAAW;AAEhD,QAAM,UAAU,QAAQ,WAAW,KAAK;AAExC,QAAM,EAAE,SAAS,MAAM,UAAU,KAAK,UAAU,aAAa,IAAI,MAAM,MAAM,CAAC,CAAC,KAAK,OAAO,OAAO;AAElG,MAAI,SAAS,CAAC,KAAK,OAAO;AACxB,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,MAAM;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,MAAM;AACR,sBAAkB,iBAAiB,KAAK,MAAM,cAAc,QAAQ,CAAC;AACrE,sBAAkB,eAAe,KAAK,aAAa,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,EACvF,WAAW,cAAc;AACvB,sBAAkB,aAAa,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,EACnE,WAAW,MAAM,QAAQ,QAAQ,KAAK,MAAM,QAAQ,QAAQ,GAAG;AAC7D,UAAM,qBAAqB,SAAS,IAAI,CAAC,KAAK,UAAU;AACtD,YAAM,MAAM,SAAS,KAAK;AAC1B,cAAI,uBAAS,GAAG;AACd,eAAO,IAAI,KAAK,GAAG,IAAI,MAAM;AAE/B,aAAO;AAAA,IACT,CAAC;AACD,kBAAc,KAAK,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAAA,EACF,OAAO;AACL,kBAAc,KAAK,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAAA,EACF;AACA,QAAM,UAAU,MAAM;AACpB,eAAO,yCAAqB,MAAM;AAAA,MAChC;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAKA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IAAU;AAAA,IACV,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,SAAS,WAAW,UAAU;AAAA,EAChC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -22,9 +22,6 @@ __export(toHaveURL_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(toHaveURL_exports);
|
|
24
24
|
var import_utils = require("playwright-core/lib/utils");
|
|
25
|
-
var import_expect = require("./expect");
|
|
26
|
-
var import_matcherHint = require("./matcherHint");
|
|
27
|
-
var import_expectBundle = require("../common/expectBundle");
|
|
28
25
|
async function toHaveURLWithPredicate(page, expected, options) {
|
|
29
26
|
const matcherName = "toHaveURL";
|
|
30
27
|
const timeout = options?.timeout ?? this.timeout;
|
|
@@ -75,18 +72,20 @@ function toHaveURLMessage(state, matcherName, expected, received, pass, timedOut
|
|
|
75
72
|
let printedDiff;
|
|
76
73
|
if (typeof expected === "function") {
|
|
77
74
|
printedExpected = `Expected: predicate to ${!state.isNot ? "succeed" : "fail"}`;
|
|
78
|
-
printedReceived = `Received: ${
|
|
75
|
+
printedReceived = `Received: ${state.utils.printReceived(receivedString)}`;
|
|
79
76
|
} else {
|
|
80
77
|
if (pass) {
|
|
81
78
|
printedExpected = `Expected pattern: not ${state.utils.printExpected(expected)}`;
|
|
82
|
-
const formattedReceived = (0,
|
|
79
|
+
const formattedReceived = (0, import_utils.printReceivedStringContainExpectedResult)(state.utils, receivedString, null);
|
|
83
80
|
printedReceived = `Received string: ${formattedReceived}`;
|
|
84
81
|
} else {
|
|
85
82
|
const labelExpected = `Expected ${typeof expected === "string" ? "string" : "pattern"}`;
|
|
86
83
|
printedDiff = state.utils.printDiffOrStringify(expected, receivedString, labelExpected, "Received string", false);
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
|
-
return (0,
|
|
86
|
+
return (0, import_utils.formatMatcherMessage)(state.utils, {
|
|
87
|
+
isNot: state.isNot,
|
|
88
|
+
promise: state.promise,
|
|
90
89
|
matcherName,
|
|
91
90
|
expectation: "expected",
|
|
92
91
|
timeout,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/toHaveURL.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { urlMatches } from 'playwright-core/lib/utils';\n\nimport { printReceivedStringContainExpectedResult } from './expect';\nimport { formatMatcherMessage } from './matcherHint';\nimport { printReceived } from '../common/expectBundle';\n\nimport type { MatcherResult } from './matcherHint';\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { Page } from 'playwright-core';\n\nexport async function toHaveURLWithPredicate(\n this: ExpectMatcherState,\n page: Page,\n expected: (url: URL) => boolean,\n options?: { ignoreCase?: boolean; timeout?: number },\n): Promise<MatcherResult<string | RegExp, string>> {\n const matcherName = 'toHaveURL';\n const timeout = options?.timeout ?? this.timeout;\n const baseURL: string | undefined = (page.context() as any)._options.baseURL;\n let conditionSucceeded = false;\n let lastCheckedURLString: string | undefined = undefined;\n try {\n await page.mainFrame().waitForURL(\n url => {\n lastCheckedURLString = url.toString();\n\n if (options?.ignoreCase) {\n return (\n !this.isNot ===\n urlMatches(\n baseURL?.toLocaleLowerCase(),\n lastCheckedURLString.toLocaleLowerCase(),\n expected,\n )\n );\n }\n\n return (\n !this.isNot === urlMatches(baseURL, lastCheckedURLString, expected)\n );\n },\n { timeout },\n );\n\n conditionSucceeded = true;\n } catch (e) {\n conditionSucceeded = false;\n }\n\n if (conditionSucceeded)\n return { name: matcherName, pass: !this.isNot, message: () => '' };\n\n return {\n name: matcherName,\n pass: this.isNot,\n message: () =>\n toHaveURLMessage(\n this,\n matcherName,\n expected,\n lastCheckedURLString,\n this.isNot,\n true,\n timeout,\n ),\n actual: lastCheckedURLString,\n timeout,\n };\n}\n\nfunction toHaveURLMessage(\n state: ExpectMatcherState,\n matcherName: string,\n expected: Function,\n received: string | undefined,\n pass: boolean,\n timedOut: boolean,\n timeout: number,\n): string {\n const receivedString = received || '';\n\n let printedReceived: string | undefined;\n let printedExpected: string | undefined;\n let printedDiff: string | undefined;\n if (typeof expected === 'function') {\n printedExpected = `Expected: predicate to ${!state.isNot ? 'succeed' : 'fail'}`;\n printedReceived = `Received: ${printReceived(receivedString)}`;\n } else {\n if (pass) {\n printedExpected = `Expected pattern: not ${state.utils.printExpected(expected)}`;\n const formattedReceived = printReceivedStringContainExpectedResult(receivedString, null);\n printedReceived = `Received string: ${formattedReceived}`;\n } else {\n const labelExpected = `Expected ${typeof expected === 'string' ? 'string' : 'pattern'}`;\n printedDiff = state.utils.printDiffOrStringify(expected, receivedString, labelExpected, 'Received string', false);\n }\n }\n\n return formatMatcherMessage(state, {\n matcherName,\n expectation: 'expected',\n timeout,\n timedOut,\n printedExpected,\n printedReceived,\n printedDiff,\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,mBAA2B;AAE3B,oBAAyD;AACzD,yBAAqC;AACrC,0BAA8B;AAM9B,eAAsB,uBAEpB,MACA,UACA,SACiD;AACjD,QAAM,cAAc;AACpB,QAAM,UAAU,SAAS,WAAW,KAAK;AACzC,QAAM,UAA+B,KAAK,QAAQ,EAAU,SAAS;AACrE,MAAI,qBAAqB;AACzB,MAAI,uBAA2C;AAC/C,MAAI;AACF,UAAM,KAAK,UAAU,EAAE;AAAA,MACnB,SAAO;AACL,+BAAuB,IAAI,SAAS;AAEpC,YAAI,SAAS,YAAY;AACvB,iBACE,CAAC,KAAK,cACN;AAAA,YACI,SAAS,kBAAkB;AAAA,YAC3B,qBAAqB,kBAAkB;AAAA,YACvC;AAAA,UACJ;AAAA,QAEJ;AAEA,eACE,CAAC,KAAK,cAAU,yBAAW,SAAS,sBAAsB,QAAQ;AAAA,MAEtE;AAAA,MACA,EAAE,QAAQ;AAAA,IACd;AAEA,yBAAqB;AAAA,EACvB,SAAS,GAAG;AACV,yBAAqB;AAAA,EACvB;AAEA,MAAI;AACF,WAAO,EAAE,MAAM,aAAa,MAAM,CAAC,KAAK,OAAO,SAAS,MAAM,GAAG;AAEnE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AAAA,IACX,SAAS,MACP;AAAA,MACI;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACJ;AAAA,IACF,QAAQ;AAAA,IACR;AAAA,EACF;AACF;AAEA,SAAS,iBACP,OACA,aACA,UACA,UACA,MACA,UACA,SACQ;AACR,QAAM,iBAAiB,YAAY;AAEnC,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,OAAO,aAAa,YAAY;AAClC,sBAAkB,0BAA0B,CAAC,MAAM,QAAQ,YAAY,MAAM;AAC7E,sBAAkB,iBAAa,mCAAc,cAAc,CAAC;AAAA,EAC9D,OAAO;AACL,QAAI,MAAM;AACR,wBAAkB,yBAAyB,MAAM,MAAM,cAAc,QAAQ,CAAC;AAC9E,YAAM,wBAAoB,wDAAyC,gBAAgB,IAAI;AACvF,wBAAkB,oBAAoB,iBAAiB;AAAA,IACzD,OAAO;AACL,YAAM,gBAAgB,YAAY,OAAO,aAAa,WAAW,WAAW,SAAS;AACrF,oBAAc,MAAM,MAAM,qBAAqB,UAAU,gBAAgB,eAAe,mBAAmB,KAAK;AAAA,IAClH;AAAA,EACF;AAEA,aAAO,yCAAqB,OAAO;AAAA,IACjC;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -34,9 +34,7 @@ module.exports = __toCommonJS(toMatchAriaSnapshot_exports);
|
|
|
34
34
|
var import_fs = __toESM(require("fs"));
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
36
|
var import_utils = require("playwright-core/lib/utils");
|
|
37
|
-
var import_matcherHint = require("./matcherHint");
|
|
38
37
|
var import_util = require("../util");
|
|
39
|
-
var import_expect = require("./expect");
|
|
40
38
|
var import_globals = require("../common/globals");
|
|
41
39
|
async function toMatchAriaSnapshot(locator, expectedParam, options = {}) {
|
|
42
40
|
const matcherName = "toMatchAriaSnapshot";
|
|
@@ -79,16 +77,18 @@ async function toMatchAriaSnapshot(locator, expectedParam, options = {}) {
|
|
|
79
77
|
if (errorMessage) {
|
|
80
78
|
printedExpected = `Expected: ${this.isNot ? "not " : ""}${this.utils.printExpected(expected)}`;
|
|
81
79
|
} else if (pass) {
|
|
82
|
-
const receivedString = (0,
|
|
80
|
+
const receivedString = (0, import_utils.printReceivedStringContainExpectedSubstring)(this.utils, typedReceived.raw, typedReceived.raw.indexOf(expected), expected.length);
|
|
83
81
|
printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;
|
|
84
82
|
printedReceived = `Received: ${receivedString}`;
|
|
85
83
|
} else {
|
|
86
84
|
printedDiff = this.utils.printDiffOrStringify(expected, typedReceived.raw, "Expected", "Received", false);
|
|
87
85
|
}
|
|
88
|
-
return (0,
|
|
86
|
+
return (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
87
|
+
isNot: this.isNot,
|
|
88
|
+
promise: this.promise,
|
|
89
89
|
matcherName,
|
|
90
90
|
expectation: "expected",
|
|
91
|
-
locator,
|
|
91
|
+
locator: locator.toString(),
|
|
92
92
|
timeout,
|
|
93
93
|
timedOut,
|
|
94
94
|
printedExpected,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/toMatchAriaSnapshot.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { escapeTemplateString, isString } from 'playwright-core/lib/utils';\n\nimport { formatMatcherMessage } from './matcherHint';\nimport { fileExistsAsync } from '../util';\nimport { printReceivedStringContainExpectedSubstring } from './expect';\nimport { currentTestInfo } from '../common/globals';\n\nimport type { MatcherResult } from './matcherHint';\nimport type { LocatorEx } from './matchers';\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { MatcherReceived } from '@injected/ariaSnapshot';\n\n\ntype ToMatchAriaSnapshotExpected = {\n name?: string;\n path?: string;\n timeout?: number;\n} | string;\n\nexport async function toMatchAriaSnapshot(\n this: ExpectMatcherState,\n locator: LocatorEx,\n expectedParam?: ToMatchAriaSnapshotExpected,\n options: { timeout?: number } = {},\n): Promise<MatcherResult<string | RegExp, string>> {\n const matcherName = 'toMatchAriaSnapshot';\n\n const testInfo = currentTestInfo();\n if (!testInfo)\n throw new Error(`toMatchAriaSnapshot() must be called during the test`);\n\n if (testInfo._projectInternal.ignoreSnapshots)\n return { pass: !this.isNot, message: () => '', name: 'toMatchAriaSnapshot', expected: '' };\n\n const updateSnapshots = testInfo.config.updateSnapshots;\n\n let expected: string;\n let timeout: number;\n let expectedPath: string | undefined;\n if (isString(expectedParam)) {\n expected = expectedParam;\n timeout = options.timeout ?? this.timeout;\n } else {\n const legacyPath = testInfo._resolveSnapshotPaths('aria', expectedParam?.name, 'dontUpdateSnapshotIndex', '.yml').absoluteSnapshotPath;\n expectedPath = testInfo._resolveSnapshotPaths('aria', expectedParam?.name, 'updateSnapshotIndex').absoluteSnapshotPath;\n // in 1.51, we changed the default template to use .aria.yml extension\n // for backwards compatibility, we check for the legacy .yml extension\n if (!(await fileExistsAsync(expectedPath)) && await fileExistsAsync(legacyPath))\n expectedPath = legacyPath;\n expected = await fs.promises.readFile(expectedPath, 'utf8').catch(() => '');\n timeout = expectedParam?.timeout ?? this.timeout;\n }\n\n const generateMissingBaseline = updateSnapshots === 'missing' && !expected;\n if (generateMissingBaseline) {\n if (this.isNot) {\n const message = `Matchers using \".not\" can't generate new baselines`;\n return { pass: this.isNot, message: () => message, name: 'toMatchAriaSnapshot' };\n } else {\n // When generating new baseline, run entire pipeline against impossible match.\n expected = `- none \"Generating new baseline\"`;\n }\n }\n\n expected = unshift(expected);\n const { matches: pass, received, log, timedOut, errorMessage } = await locator._expect('to.match.aria', { expectedValue: expected, isNot: this.isNot, timeout });\n const typedReceived = received as MatcherReceived;\n\n const message = () => {\n let printedExpected: string | undefined;\n let printedReceived: string | undefined;\n let printedDiff: string | undefined;\n if (errorMessage) {\n printedExpected = `Expected: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(expected)}`;\n } else if (pass) {\n const receivedString = printReceivedStringContainExpectedSubstring(typedReceived.raw, typedReceived.raw.indexOf(expected), expected.length);\n printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;\n printedReceived = `Received: ${receivedString}`;\n } else {\n printedDiff = this.utils.printDiffOrStringify(expected, typedReceived.raw, 'Expected', 'Received', false);\n }\n return formatMatcherMessage(this, {\n matcherName,\n expectation: 'expected',\n locator,\n timeout,\n timedOut,\n printedExpected,\n printedReceived,\n printedDiff,\n errorMessage,\n log,\n });\n };\n\n if (errorMessage)\n return { pass: this.isNot, message, name: 'toMatchAriaSnapshot', expected };\n\n if (!this.isNot) {\n if ((updateSnapshots === 'all') ||\n (updateSnapshots === 'changed' && pass === this.isNot) ||\n generateMissingBaseline) {\n if (expectedPath) {\n await fs.promises.mkdir(path.dirname(expectedPath), { recursive: true });\n await fs.promises.writeFile(expectedPath, typedReceived.regex, 'utf8');\n const relativePath = path.relative(process.cwd(), expectedPath);\n if (updateSnapshots === 'missing') {\n const message = `A snapshot doesn't exist at ${relativePath}, writing actual.`;\n testInfo._hasNonRetriableError = true;\n testInfo._failWithError(new Error(message));\n } else {\n const message = `A snapshot is generated at ${relativePath}.`;\n /* eslint-disable no-console */\n console.log(message);\n }\n return { pass: true, message: () => '', name: 'toMatchAriaSnapshot' };\n } else {\n const suggestedRebaseline = `\\`\\n${escapeTemplateString(indent(typedReceived.regex, '{indent} '))}\\n{indent}\\``;\n if (updateSnapshots === 'missing') {\n const message = 'A snapshot is not provided, generating new baseline.';\n testInfo._hasNonRetriableError = true;\n testInfo._failWithError(new Error(message));\n }\n // TODO: ideally, we should return \"pass: true\" here because this matcher passes\n // when regenerating baselines. However, we can only access suggestedRebaseline in case\n // of an error, so we fail here and workaround it in the expect implementation.\n return { pass: false, message: () => '', name: 'toMatchAriaSnapshot', suggestedRebaseline };\n }\n }\n }\n\n return {\n name: matcherName,\n expected,\n message,\n pass,\n actual: received,\n log,\n timeout: timedOut ? timeout : undefined,\n };\n}\n\nfunction unshift(snapshot: string): string {\n const lines = snapshot.split('\\n');\n let whitespacePrefixLength = 100;\n for (const line of lines) {\n if (!line.trim())\n continue;\n const match = line.match(/^(\\s*)/);\n if (match && match[1].length < whitespacePrefixLength)\n whitespacePrefixLength = match[1].length;\n }\n return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\\n');\n}\n\nfunction indent(snapshot: string, indent: string): string {\n return snapshot.split('\\n').map(line => indent + line).join('\\n');\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,gBAAe;AACf,kBAAiB;AAEjB,mBAA+C;AAE/C,yBAAqC;AACrC,kBAAgC;AAChC,oBAA4D;AAC5D,qBAAgC;AAchC,eAAsB,oBAEpB,SACA,eACA,UAAgC,CAAC,GACgB;AACjD,QAAM,cAAc;AAEpB,QAAM,eAAW,gCAAgB;AACjC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,sDAAsD;AAExE,MAAI,SAAS,iBAAiB;AAC5B,WAAO,EAAE,MAAM,CAAC,KAAK,OAAO,SAAS,MAAM,IAAI,MAAM,uBAAuB,UAAU,GAAG;AAE3F,QAAM,kBAAkB,SAAS,OAAO;AAExC,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,UAAI,uBAAS,aAAa,GAAG;AAC3B,eAAW;AACX,cAAU,QAAQ,WAAW,KAAK;AAAA,EACpC,OAAO;AACL,UAAM,aAAa,SAAS,sB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;AAAA,IACA,SAAS,WAAW,UAAU;AAAA,EAChC;AACF;AAEA,SAAS,QAAQ,UAA0B;AACzC,QAAM,QAAQ,SAAS,MAAM,IAAI;AACjC,MAAI,yBAAyB;AAC7B,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,KAAK,KAAK;AACb;AACF,UAAM,QAAQ,KAAK,MAAM,QAAQ;AACjC,QAAI,SAAS,MAAM,CAAC,EAAE,SAAS;AAC7B,+BAAyB,MAAM,CAAC,EAAE;AAAA,EACtC;AACA,SAAO,MAAM,OAAO,OAAK,EAAE,KAAK,CAAC,EAAE,IAAI,UAAQ,KAAK,UAAU,sBAAsB,CAAC,EAAE,KAAK,IAAI;AAClG;AAEA,SAAS,OAAO,UAAkBE,SAAwB;AACxD,SAAO,SAAS,MAAM,IAAI,EAAE,IAAI,UAAQA,UAAS,IAAI,EAAE,KAAK,IAAI;AAClE;",
|
|
6
|
+
"names": ["fs", "message", "path", "indent"]
|
|
7
|
+
}
|
|
@@ -39,7 +39,6 @@ var import_utils = require("playwright-core/lib/utils");
|
|
|
39
39
|
var import_utils2 = require("playwright-core/lib/utils");
|
|
40
40
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
41
41
|
var import_util = require("../util");
|
|
42
|
-
var import_matcherHint = require("./matcherHint");
|
|
43
42
|
var import_globals = require("../common/globals");
|
|
44
43
|
const NonConfigProperties = [
|
|
45
44
|
"clip",
|
|
@@ -50,7 +49,7 @@ const NonConfigProperties = [
|
|
|
50
49
|
"timeout"
|
|
51
50
|
];
|
|
52
51
|
class SnapshotHelper {
|
|
53
|
-
constructor(testInfo, matcherName, locator, anonymousSnapshotExtension, configOptions, nameOrOptions, optOptions) {
|
|
52
|
+
constructor(state, testInfo, matcherName, locator, anonymousSnapshotExtension, configOptions, nameOrOptions, optOptions) {
|
|
54
53
|
let name;
|
|
55
54
|
if (Array.isArray(nameOrOptions) || typeof nameOrOptions === "string") {
|
|
56
55
|
name = nameOrOptions;
|
|
@@ -90,6 +89,7 @@ class SnapshotHelper {
|
|
|
90
89
|
this.mimeType = import_utilsBundle.mime.getType(import_path.default.basename(this.expectedPath)) ?? "application/octet-stream";
|
|
91
90
|
this.comparator = (0, import_utils.getComparator)(this.mimeType);
|
|
92
91
|
this.testInfo = testInfo;
|
|
92
|
+
this.state = state;
|
|
93
93
|
this.kind = this.mimeType.startsWith("image/") ? "Screenshot" : "Snapshot";
|
|
94
94
|
}
|
|
95
95
|
createMatcherResult(message, pass, log) {
|
|
@@ -162,7 +162,7 @@ class SnapshotHelper {
|
|
|
162
162
|
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-diff"), contentType: this.mimeType, path: this.diffPath });
|
|
163
163
|
}
|
|
164
164
|
if (log?.length)
|
|
165
|
-
output.push((0,
|
|
165
|
+
output.push((0, import_utils.callLogText)(this.state.utils, log));
|
|
166
166
|
else
|
|
167
167
|
output.push("");
|
|
168
168
|
return this.createMatcherResult(output.join("\n"), false, log);
|
|
@@ -181,6 +181,7 @@ function toMatchSnapshot(received, nameOrOptions = {}, optOptions = {}) {
|
|
|
181
181
|
return { pass: !this.isNot, message: () => "", name: "toMatchSnapshot", expected: nameOrOptions };
|
|
182
182
|
const configOptions = testInfo._projectInternal.expect?.toMatchSnapshot || {};
|
|
183
183
|
const helper = new SnapshotHelper(
|
|
184
|
+
this,
|
|
184
185
|
testInfo,
|
|
185
186
|
"toMatchSnapshot",
|
|
186
187
|
void 0,
|
|
@@ -216,7 +217,7 @@ function toMatchSnapshot(received, nameOrOptions = {}, optOptions = {}) {
|
|
|
216
217
|
const result = helper.comparator(received, expected, helper.options);
|
|
217
218
|
if (!result)
|
|
218
219
|
return helper.handleMatching();
|
|
219
|
-
const header = (0,
|
|
220
|
+
const header = (0, import_utils.formatMatcherMessage)(this.utils, { promise: this.promise, isNot: this.isNot, matcherName: "toMatchSnapshot", receiver: (0, import_utils.isString)(received) ? "string" : "Buffer", expectation: "expected" });
|
|
220
221
|
return helper.handleDifferent(received, expected, void 0, result.diff, header, result.errorMessage, void 0, this._stepInfo);
|
|
221
222
|
}
|
|
222
223
|
function toHaveScreenshotStepTitle(nameOrOptions = {}, optOptions = {}) {
|
|
@@ -236,7 +237,7 @@ async function toHaveScreenshot(pageOrLocator, nameOrOptions = {}, optOptions =
|
|
|
236
237
|
(0, import_util.expectTypes)(pageOrLocator, ["Page", "Locator"], "toHaveScreenshot");
|
|
237
238
|
const [page, locator] = pageOrLocator.constructor.name === "Page" ? [pageOrLocator, void 0] : [pageOrLocator.page(), pageOrLocator];
|
|
238
239
|
const configOptions = testInfo._projectInternal.expect?.toHaveScreenshot || {};
|
|
239
|
-
const helper = new SnapshotHelper(testInfo, "toHaveScreenshot", locator, void 0, configOptions, nameOrOptions, optOptions);
|
|
240
|
+
const helper = new SnapshotHelper(this, testInfo, "toHaveScreenshot", locator, void 0, configOptions, nameOrOptions, optOptions);
|
|
240
241
|
if (!helper.expectedPath.toLowerCase().endsWith(".png"))
|
|
241
242
|
throw new Error(`Screenshot name "${import_path.default.basename(helper.expectedPath)}" must have '.png' extension`);
|
|
242
243
|
(0, import_util.expectTypes)(pageOrLocator, ["Page", "Locator"], "toHaveScreenshot");
|
|
@@ -273,7 +274,7 @@ async function toHaveScreenshot(pageOrLocator, nameOrOptions = {}, optOptions =
|
|
|
273
274
|
if (!hasSnapshot) {
|
|
274
275
|
const { actual: actual2, previous: previous2, diff: diff2, errorMessage: errorMessage2, log: log2, timedOut: timedOut2 } = await page._expectScreenshot(expectScreenshotOptions);
|
|
275
276
|
if (errorMessage2) {
|
|
276
|
-
const header2 = (0,
|
|
277
|
+
const header2 = (0, import_utils.formatMatcherMessage)(this.utils, { promise: this.promise, isNot: this.isNot, matcherName: "toHaveScreenshot", locator: locator?.toString(), expectation: "expected", timeout, timedOut: timedOut2 });
|
|
277
278
|
return helper.handleDifferent(actual2, void 0, previous2, diff2, header2, errorMessage2, log2, this._stepInfo);
|
|
278
279
|
}
|
|
279
280
|
return helper.handleMissing(actual2, this._stepInfo);
|
|
@@ -297,11 +298,11 @@ async function toHaveScreenshot(pageOrLocator, nameOrOptions = {}, optOptions =
|
|
|
297
298
|
if (helper.updateSnapshots === "changed" || helper.updateSnapshots === "all") {
|
|
298
299
|
if (actual)
|
|
299
300
|
return writeFiles(actual);
|
|
300
|
-
let header2 = (0,
|
|
301
|
+
let header2 = (0, import_utils.formatMatcherMessage)(this.utils, { promise: this.promise, isNot: this.isNot, matcherName: "toHaveScreenshot", locator: locator?.toString(), expectation: "expected", timeout, timedOut });
|
|
301
302
|
header2 += " Failed to re-generate expected.\n";
|
|
302
303
|
return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header2, errorMessage, log, this._stepInfo);
|
|
303
304
|
}
|
|
304
|
-
const header = (0,
|
|
305
|
+
const header = (0, import_utils.formatMatcherMessage)(this.utils, { promise: this.promise, isNot: this.isNot, matcherName: "toHaveScreenshot", locator: locator?.toString(), expectation: "expected", timeout, timedOut });
|
|
305
306
|
return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log, this._stepInfo);
|
|
306
307
|
}
|
|
307
308
|
function writeFileSync(aPath, content) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/toMatchSnapshot.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { compareBuffersOrStrings, getComparator, isString } from 'playwright-core/lib/utils';\nimport { colors } from 'playwright-core/lib/utils';\nimport { mime } from 'playwright-core/lib/utilsBundle';\n\nimport { addSuffixToFilePath, expectTypes } from '../util';\nimport { callLogText, formatMatcherMessage } from './matcherHint';\nimport { currentTestInfo } from '../common/globals';\n\nimport type { MatcherResult } from './matcherHint';\nimport type { ExpectMatcherStateInternal } from './matchers';\nimport type { FullProjectInternal } from '../common/config';\nimport type { TestInfoImpl, TestStepInfoImpl } from '../worker/testInfo';\nimport type { Locator, Page } from 'playwright-core';\nimport type { ExpectScreenshotOptions, Page as PageEx } from 'playwright-core/lib/client/page';\nimport type { Comparator, ImageComparatorOptions } from 'playwright-core/lib/utils';\n\ntype NameOrSegments = string | string[];\n\ntype ImageMatcherResult = MatcherResult<string, string> & { diff?: string };\n\ntype ToHaveScreenshotConfigOptions = NonNullable<NonNullable<FullProjectInternal['expect']>['toHaveScreenshot']> & {\n _comparator?: string;\n};\n\ntype ToHaveScreenshotOptions = ToHaveScreenshotConfigOptions & {\n clip?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n fullPage?: boolean;\n mask?: Array<Locator>;\n maskColor?: string;\n omitBackground?: boolean;\n timeout?: number;\n};\n\n// Keep in sync with above (begin).\nconst NonConfigProperties: (keyof ToHaveScreenshotOptions)[] = [\n 'clip',\n 'fullPage',\n 'mask',\n 'maskColor',\n 'omitBackground',\n 'timeout',\n];\n// Keep in sync with above (end).\n\nclass SnapshotHelper {\n readonly testInfo: TestInfoImpl;\n readonly name: string;\n readonly attachmentBaseName: string;\n readonly legacyExpectedPath: string;\n readonly previousPath: string;\n readonly expectedPath: string;\n readonly actualPath: string;\n readonly diffPath: string;\n readonly mimeType: string;\n readonly kind: 'Screenshot'|'Snapshot';\n readonly updateSnapshots: 'all' | 'changed' | 'missing' | 'none';\n readonly comparator: Comparator;\n readonly options: Omit<ToHaveScreenshotOptions, '_comparator'> & { comparator?: string };\n readonly matcherName: string;\n readonly locator: Locator | undefined;\n\n constructor(\n testInfo: TestInfoImpl,\n matcherName: 'toMatchSnapshot' | 'toHaveScreenshot',\n locator: Locator | undefined,\n anonymousSnapshotExtension: string | undefined,\n configOptions: ToHaveScreenshotConfigOptions,\n nameOrOptions: NameOrSegments | { name?: NameOrSegments } & ToHaveScreenshotOptions,\n optOptions: ToHaveScreenshotOptions,\n ) {\n let name: NameOrSegments | undefined;\n if (Array.isArray(nameOrOptions) || typeof nameOrOptions === 'string') {\n name = nameOrOptions;\n this.options = { ...optOptions };\n } else {\n const { name: nameFromOptions, ...options } = nameOrOptions;\n this.options = options;\n name = nameFromOptions;\n }\n\n this.name = Array.isArray(name) ? name.join(path.sep) : name || '';\n const resolvedPaths = testInfo._resolveSnapshotPaths(matcherName === 'toHaveScreenshot' ? 'screenshot' : 'snapshot', name, 'updateSnapshotIndex', anonymousSnapshotExtension);\n this.expectedPath = resolvedPaths.absoluteSnapshotPath;\n this.attachmentBaseName = resolvedPaths.relativeOutputPath;\n\n const outputBasePath = testInfo._getOutputPath(resolvedPaths.relativeOutputPath);\n this.legacyExpectedPath = addSuffixToFilePath(outputBasePath, '-expected');\n this.previousPath = addSuffixToFilePath(outputBasePath, '-previous');\n this.actualPath = addSuffixToFilePath(outputBasePath, '-actual');\n this.diffPath = addSuffixToFilePath(outputBasePath, '-diff');\n\n const filteredConfigOptions = { ...configOptions };\n for (const prop of NonConfigProperties)\n delete (filteredConfigOptions as any)[prop];\n this.options = {\n ...filteredConfigOptions,\n ...this.options,\n };\n\n // While comparator is not a part of the public API, it is translated here.\n if ((this.options as any)._comparator) {\n this.options.comparator = (this.options as any)._comparator;\n delete (this.options as any)._comparator;\n }\n\n if (this.options.maxDiffPixels !== undefined && this.options.maxDiffPixels < 0)\n throw new Error('`maxDiffPixels` option value must be non-negative integer');\n\n if (this.options.maxDiffPixelRatio !== undefined && (this.options.maxDiffPixelRatio < 0 || this.options.maxDiffPixelRatio > 1))\n throw new Error('`maxDiffPixelRatio` option value must be between 0 and 1');\n\n this.matcherName = matcherName;\n this.locator = locator;\n\n this.updateSnapshots = testInfo.config.updateSnapshots;\n this.mimeType = mime.getType(path.basename(this.expectedPath)) ?? 'application/octet-stream';\n this.comparator = getComparator(this.mimeType);\n\n this.testInfo = testInfo;\n this.kind = this.mimeType.startsWith('image/') ? 'Screenshot' : 'Snapshot';\n }\n\n createMatcherResult(message: string, pass: boolean, log?: string[]): ImageMatcherResult {\n const unfiltered: ImageMatcherResult = {\n name: this.matcherName,\n expected: this.expectedPath,\n actual: this.actualPath,\n diff: this.diffPath,\n pass,\n message: () => message,\n log,\n };\n return Object.fromEntries(Object.entries(unfiltered).filter(([_, v]) => v !== undefined)) as ImageMatcherResult;\n }\n\n handleMissingNegated(): ImageMatcherResult {\n const isWriteMissingMode = this.updateSnapshots !== 'none';\n const message = `A snapshot doesn't exist at ${this.expectedPath}${isWriteMissingMode ? ', matchers using \".not\" won\\'t write them automatically.' : '.'}`;\n // NOTE: 'isNot' matcher implies inversed value.\n return this.createMatcherResult(message, true);\n }\n\n handleDifferentNegated(): ImageMatcherResult {\n // NOTE: 'isNot' matcher implies inversed value.\n return this.createMatcherResult('', false);\n }\n\n handleMatchingNegated(): ImageMatcherResult {\n const message = [\n colors.red(`${this.kind} comparison failed:`),\n '',\n indent('Expected result should be different from the actual one.', ' '),\n ].join('\\n');\n // NOTE: 'isNot' matcher implies inversed value.\n return this.createMatcherResult(message, true);\n }\n\n handleMissing(actual: Buffer | string, step: TestStepInfoImpl | undefined): ImageMatcherResult {\n const isWriteMissingMode = this.updateSnapshots !== 'none';\n if (isWriteMissingMode)\n writeFileSync(this.expectedPath, actual);\n step?._attachToStep({ name: addSuffixToFilePath(this.attachmentBaseName, '-expected'), contentType: this.mimeType, path: this.expectedPath });\n writeFileSync(this.actualPath, actual);\n step?._attachToStep({ name: addSuffixToFilePath(this.attachmentBaseName, '-actual'), contentType: this.mimeType, path: this.actualPath });\n const message = `A snapshot doesn't exist at ${this.expectedPath}${isWriteMissingMode ? ', writing actual.' : '.'}`;\n if (this.updateSnapshots === 'all' || this.updateSnapshots === 'changed') {\n /* eslint-disable no-console */\n console.log(message);\n return this.createMatcherResult(message, true);\n }\n if (this.updateSnapshots === 'missing') {\n this.testInfo._hasNonRetriableError = true;\n this.testInfo._failWithError(new Error(message));\n return this.createMatcherResult('', true);\n }\n return this.createMatcherResult(message, false);\n }\n\n handleDifferent(\n actual: Buffer | string | undefined,\n expected: Buffer | string | undefined,\n previous: Buffer | string | undefined,\n diff: Buffer | string | undefined,\n header: string,\n diffError: string,\n log: string[] | undefined,\n step: TestStepInfoImpl | undefined): ImageMatcherResult {\n const output = [`${header}${indent(diffError, ' ')}`];\n if (this.name) {\n output.push('');\n output.push(` Snapshot: ${this.name}`);\n }\n if (expected !== undefined) {\n // Copy the expectation inside the `test-results/` folder for backwards compatibility,\n // so that one can upload `test-results/` directory and have all the data inside.\n writeFileSync(this.legacyExpectedPath, expected);\n step?._attachToStep({ name: addSuffixToFilePath(this.attachmentBaseName, '-expected'), contentType: this.mimeType, path: this.expectedPath });\n }\n if (previous !== undefined) {\n writeFileSync(this.previousPath, previous);\n step?._attachToStep({ name: addSuffixToFilePath(this.attachmentBaseName, '-previous'), contentType: this.mimeType, path: this.previousPath });\n }\n if (actual !== undefined) {\n writeFileSync(this.actualPath, actual);\n step?._attachToStep({ name: addSuffixToFilePath(this.attachmentBaseName, '-actual'), contentType: this.mimeType, path: this.actualPath });\n }\n if (diff !== undefined) {\n writeFileSync(this.diffPath, diff);\n step?._attachToStep({ name: addSuffixToFilePath(this.attachmentBaseName, '-diff'), contentType: this.mimeType, path: this.diffPath });\n }\n\n if (log?.length)\n output.push(callLogText(log));\n else\n output.push('');\n\n return this.createMatcherResult(output.join('\\n'), false, log);\n }\n\n handleMatching(): ImageMatcherResult {\n return this.createMatcherResult('', true);\n }\n}\n\nexport function toMatchSnapshot(\n this: ExpectMatcherStateInternal,\n received: Buffer | string,\n nameOrOptions: NameOrSegments | { name?: NameOrSegments } & ImageComparatorOptions = {},\n optOptions: ImageComparatorOptions = {}\n): MatcherResult<NameOrSegments | { name?: NameOrSegments }, string> {\n const testInfo = currentTestInfo();\n if (!testInfo)\n throw new Error(`toMatchSnapshot() must be called during the test`);\n if (received instanceof Promise)\n throw new Error('An unresolved Promise was passed to toMatchSnapshot(), make sure to resolve it by adding await to it.');\n\n if (testInfo._projectInternal.ignoreSnapshots)\n return { pass: !this.isNot, message: () => '', name: 'toMatchSnapshot', expected: nameOrOptions };\n\n const configOptions = testInfo._projectInternal.expect?.toMatchSnapshot || {};\n const helper = new SnapshotHelper(\n testInfo, 'toMatchSnapshot', undefined, '.' + determineFileExtension(received),\n configOptions, nameOrOptions, optOptions);\n\n if (this.isNot) {\n if (!fs.existsSync(helper.expectedPath))\n return helper.handleMissingNegated();\n const isDifferent = !!helper.comparator(received, fs.readFileSync(helper.expectedPath), helper.options);\n return isDifferent ? helper.handleDifferentNegated() : helper.handleMatchingNegated();\n }\n\n if (!fs.existsSync(helper.expectedPath))\n return helper.handleMissing(received, this._stepInfo);\n\n const expected = fs.readFileSync(helper.expectedPath);\n\n if (helper.updateSnapshots === 'all') {\n if (!compareBuffersOrStrings(received, expected))\n return helper.handleMatching();\n writeFileSync(helper.expectedPath, received);\n /* eslint-disable no-console */\n console.log(helper.expectedPath + ' is not the same, writing actual.');\n return helper.createMatcherResult(helper.expectedPath + ' running with --update-snapshots, writing actual.', true);\n }\n\n if (helper.updateSnapshots === 'changed') {\n const result = helper.comparator(received, expected, helper.options);\n if (!result)\n return helper.handleMatching();\n writeFileSync(helper.expectedPath, received);\n /* eslint-disable no-console */\n console.log(helper.expectedPath + ' does not match, writing actual.');\n return helper.createMatcherResult(helper.expectedPath + ' running with --update-snapshots, writing actual.', true);\n }\n\n const result = helper.comparator(received, expected, helper.options);\n if (!result)\n return helper.handleMatching();\n\n const header = formatMatcherMessage(this, { matcherName: 'toMatchSnapshot', receiver: isString(received) ? 'string' : 'Buffer', expectation: 'expected' });\n return helper.handleDifferent(received, expected, undefined, result.diff, header, result.errorMessage, undefined, this._stepInfo);\n}\n\nexport function toHaveScreenshotStepTitle(\n nameOrOptions: NameOrSegments | { name?: NameOrSegments } & ToHaveScreenshotOptions = {},\n optOptions: ToHaveScreenshotOptions = {}\n): string {\n let name: NameOrSegments | undefined;\n if (typeof nameOrOptions === 'object' && !Array.isArray(nameOrOptions))\n name = nameOrOptions.name;\n else\n name = nameOrOptions;\n return Array.isArray(name) ? name.join(path.sep) : name || '';\n}\n\nexport async function toHaveScreenshot(\n this: ExpectMatcherStateInternal,\n pageOrLocator: Page | Locator,\n nameOrOptions: NameOrSegments | { name?: NameOrSegments } & ToHaveScreenshotOptions = {},\n optOptions: ToHaveScreenshotOptions = {}\n): Promise<MatcherResult<NameOrSegments | { name?: NameOrSegments }, string>> {\n const testInfo = currentTestInfo();\n if (!testInfo)\n throw new Error(`toHaveScreenshot() must be called during the test`);\n\n if (testInfo._projectInternal.ignoreSnapshots)\n return { pass: !this.isNot, message: () => '', name: 'toHaveScreenshot', expected: nameOrOptions };\n\n expectTypes(pageOrLocator, ['Page', 'Locator'], 'toHaveScreenshot');\n const [page, locator] = pageOrLocator.constructor.name === 'Page' ? [(pageOrLocator as PageEx), undefined] : [(pageOrLocator as Locator).page() as PageEx, pageOrLocator as Locator];\n const configOptions = testInfo._projectInternal.expect?.toHaveScreenshot || {};\n const helper = new SnapshotHelper(testInfo, 'toHaveScreenshot', locator, undefined, configOptions, nameOrOptions, optOptions);\n if (!helper.expectedPath.toLowerCase().endsWith('.png'))\n throw new Error(`Screenshot name \"${path.basename(helper.expectedPath)}\" must have '.png' extension`);\n expectTypes(pageOrLocator, ['Page', 'Locator'], 'toHaveScreenshot');\n const style = await loadScreenshotStyles(helper.options.stylePath);\n const timeout = helper.options.timeout ?? this.timeout;\n const expectScreenshotOptions: ExpectScreenshotOptions = {\n locator,\n animations: helper.options.animations ?? 'disabled',\n caret: helper.options.caret ?? 'hide',\n clip: helper.options.clip,\n fullPage: helper.options.fullPage,\n mask: helper.options.mask,\n maskColor: helper.options.maskColor,\n omitBackground: helper.options.omitBackground,\n scale: helper.options.scale ?? 'css',\n style,\n isNot: !!this.isNot,\n timeout,\n comparator: helper.options.comparator,\n maxDiffPixels: helper.options.maxDiffPixels,\n maxDiffPixelRatio: helper.options.maxDiffPixelRatio,\n threshold: helper.options.threshold,\n };\n\n const hasSnapshot = fs.existsSync(helper.expectedPath);\n if (this.isNot) {\n if (!hasSnapshot)\n return helper.handleMissingNegated();\n\n // Having `errorMessage` means we timed out while waiting\n // for screenshots not to match, so screenshots\n // are actually the same in the end.\n expectScreenshotOptions.expected = await fs.promises.readFile(helper.expectedPath);\n const isDifferent = !(await page._expectScreenshot(expectScreenshotOptions)).errorMessage;\n return isDifferent ? helper.handleDifferentNegated() : helper.handleMatchingNegated();\n }\n\n // Fast path: there's no screenshot and we don't intend to update it.\n if (helper.updateSnapshots === 'none' && !hasSnapshot)\n return helper.createMatcherResult(`A snapshot doesn't exist at ${helper.expectedPath}.`, false);\n\n if (!hasSnapshot) {\n // Regenerate a new screenshot by waiting until two screenshots are the same.\n const { actual, previous, diff, errorMessage, log, timedOut } = await page._expectScreenshot(expectScreenshotOptions);\n // We tried re-generating new snapshot but failed.\n // This can be due to e.g. spinning animation, so we want to show it as a diff.\n if (errorMessage) {\n const header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout, timedOut });\n return helper.handleDifferent(actual, undefined, previous, diff, header, errorMessage, log, this._stepInfo);\n }\n\n // We successfully generated new screenshot.\n return helper.handleMissing(actual!, this._stepInfo);\n }\n\n // General case:\n // - snapshot exists\n // - regular matcher (i.e. not a `.not`)\n const expected = await fs.promises.readFile(helper.expectedPath);\n expectScreenshotOptions.expected = helper.updateSnapshots === 'all' ? undefined : expected;\n\n const { actual, previous, diff, errorMessage, log, timedOut } = await page._expectScreenshot(expectScreenshotOptions);\n const writeFiles = (actualBuffer: Buffer) => {\n writeFileSync(helper.expectedPath, actualBuffer);\n writeFileSync(helper.actualPath, actualBuffer);\n /* eslint-disable no-console */\n console.log(helper.expectedPath + ' is re-generated, writing actual.');\n return helper.createMatcherResult(helper.expectedPath + ' running with --update-snapshots, writing actual.', true);\n };\n\n if (!errorMessage) {\n // Screenshot is matching, but is not necessarily the same as the expected.\n if (helper.updateSnapshots === 'all' && actual && compareBuffersOrStrings(actual, expected)) {\n console.log(helper.expectedPath + ' is re-generated, writing actual.');\n return writeFiles(actual);\n }\n return helper.handleMatching();\n }\n\n if (helper.updateSnapshots === 'changed' || helper.updateSnapshots === 'all') {\n if (actual)\n return writeFiles(actual);\n let header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout, timedOut });\n header += ' Failed to re-generate expected.\\n';\n return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log, this._stepInfo);\n }\n\n const header = formatMatcherMessage(this, { matcherName: 'toHaveScreenshot', locator, expectation: 'expected', timeout, timedOut });\n return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log, this._stepInfo);\n}\n\nfunction writeFileSync(aPath: string, content: Buffer | string) {\n fs.mkdirSync(path.dirname(aPath), { recursive: true });\n fs.writeFileSync(aPath, content);\n}\n\nfunction indent(lines: string, tab: string) {\n return lines.replace(/^(?=.+$)/gm, tab);\n}\n\nfunction determineFileExtension(file: string | Buffer): string {\n if (typeof file === 'string')\n return 'txt';\n if (compareMagicBytes(file, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))\n return 'png';\n if (compareMagicBytes(file, [0xff, 0xd8, 0xff]))\n return 'jpg';\n return 'dat';\n}\n\nfunction compareMagicBytes(file: Buffer, magicBytes: number[]): boolean {\n return Buffer.compare(Buffer.from(magicBytes), file.slice(0, magicBytes.length)) === 0;\n}\n\nasync function loadScreenshotStyles(stylePath?: string | string[]): Promise<string | undefined> {\n if (!stylePath)\n return;\n\n const stylePaths = Array.isArray(stylePath) ? stylePath : [stylePath];\n const styles = await Promise.all(stylePaths.map(async stylePath => {\n const text = await fs.promises.readFile(stylePath, 'utf8');\n return text.trim();\n }));\n return styles.join('\\n').trim() || undefined;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,gBAAe;AACf,kBAAiB;AAEjB,mBAAiE;AACjE,IAAAA,gBAAuB;AACvB,yBAAqB;AAErB,kBAAiD;AACjD,yBAAkD;AAClD,qBAAgC;AAiChC,MAAM,sBAAyD;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,eAAe;AAAA,EAiBnB,YACE,UACA,aACA,SACA,4BACA,eACA,eACA,YACA;AACA,QAAI;AACJ,QAAI,MAAM,QAAQ,aAAa,KAAK,OAAO,kBAAkB,UAAU;AACrE,aAAO;AACP,WAAK,UAAU,EAAE,GAAG,WAAW;AAAA,IACjC,OAAO;AACL,YAAM,EAAE,MAAM,iBAAiB,GAAG,QAAQ,IAAI;AAC9C,WAAK,UAAU;AACf,aAAO;AAAA,IACT;AAEA,SAAK,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,YAAAC,QAAK,GAAG,IAAI,QAAQ;AAChE,UAAM,gBAAgB,SAAS,sBAAsB,gBAAgB,qBAAqB,eAAe,YAAY,MAAM,uBAAuB,0BAA0B;AAC5K,SAAK,eAAe,cAAc;AAClC,SAAK,qBAAqB,cAAc;AAExC,UAAM,iBAAiB,SAAS,eAAe,cAAc,kBAAkB;AAC/E,SAAK,yBAAqB,iCAAoB,gBAAgB,WAAW;AACzE,SAAK,mBAAe,iCAAoB,gBAAgB,WAAW;AACnE,SAAK,iBAAa,iCAAoB,gBAAgB,SAAS;AAC/D,SAAK,eAAW,iCAAoB,gBAAgB,OAAO;AAE3D,UAAM,wBAAwB,EAAE,GAAG,cAAc;AACjD,eAAW,QAAQ;AACjB,aAAQ,sBAA8B,IAAI;AAC5C,SAAK,U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Q,cAAc,KAAK,KAAK,SAAS;AACnI;AAEA,SAAS,cAAc,OAAe,SAA0B;AAC9D,YAAAR,QAAG,UAAU,YAAAD,QAAK,QAAQ,KAAK,GAAG,EAAE,WAAW,KAAK,CAAC;AACrD,YAAAC,QAAG,cAAc,OAAO,OAAO;AACjC;AAEA,SAAS,OAAO,OAAe,KAAa;AAC1C,SAAO,MAAM,QAAQ,cAAc,GAAG;AACxC;AAEA,SAAS,uBAAuB,MAA+B;AAC7D,MAAI,OAAO,SAAS;AAClB,WAAO;AACT,MAAI,kBAAkB,MAAM,CAAC,KAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,EAAI,CAAC;AAC1E,WAAO;AACT,MAAI,kBAAkB,MAAM,CAAC,KAAM,KAAM,GAAI,CAAC;AAC5C,WAAO;AACT,SAAO;AACT;AAEA,SAAS,kBAAkB,MAAc,YAA+B;AACtE,SAAO,OAAO,QAAQ,OAAO,KAAK,UAAU,GAAG,KAAK,MAAM,GAAG,WAAW,MAAM,CAAC,MAAM;AACvF;AAEA,eAAe,qBAAqB,WAA4D;AAC9F,MAAI,CAAC;AACH;AAEF,QAAM,aAAa,MAAM,QAAQ,SAAS,IAAI,YAAY,CAAC,SAAS;AACpE,QAAM,SAAS,MAAM,QAAQ,IAAI,WAAW,IAAI,OAAMS,eAAa;AACjE,UAAM,OAAO,MAAM,UAAAT,QAAG,SAAS,SAASS,YAAW,MAAM;AACzD,WAAO,KAAK,KAAK;AAAA,EACnB,CAAC,CAAC;AACF,SAAO,OAAO,KAAK,IAAI,EAAE,KAAK,KAAK;AACrC;",
|
|
6
|
+
"names": ["import_utils", "path", "fs", "result", "actual", "previous", "diff", "errorMessage", "log", "timedOut", "header", "stylePath"]
|
|
7
|
+
}
|
|
@@ -21,17 +21,15 @@ __export(toMatchText_exports, {
|
|
|
21
21
|
toMatchText: () => toMatchText
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(toMatchText_exports);
|
|
24
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
24
25
|
var import_util = require("../util");
|
|
25
|
-
var import_expect = require("./expect");
|
|
26
|
-
var import_matcherHint = require("./matcherHint");
|
|
27
|
-
var import_expectBundle = require("../common/expectBundle");
|
|
28
26
|
async function toMatchText(matcherName, receiver, receiverType, query, expected, options = {}) {
|
|
29
27
|
(0, import_util.expectTypes)(receiver, [receiverType], matcherName);
|
|
30
28
|
const locator = receiverType === "Locator" ? receiver : void 0;
|
|
31
29
|
if (!(typeof expected === "string") && !(expected && typeof expected.test === "function")) {
|
|
32
|
-
const errorMessage2 = `Error: ${
|
|
30
|
+
const errorMessage2 = `Error: ${this.utils.EXPECTED_COLOR("expected")} value must be a string or regular expression
|
|
33
31
|
${this.utils.printWithType("Expected", expected, this.utils.printExpected)}`;
|
|
34
|
-
throw new Error((0,
|
|
32
|
+
throw new Error((0, import_utils.formatMatcherMessage)(this.utils, { promise: this.promise, isNot: this.isNot, locator: locator?.toString(), matcherName, expectation: "expected", errorMessage: errorMessage2 }));
|
|
35
33
|
}
|
|
36
34
|
const timeout = options.timeout ?? this.timeout;
|
|
37
35
|
const { matches: pass, received, log, timedOut, errorMessage } = await query(!!this.isNot, timeout);
|
|
@@ -53,13 +51,13 @@ ${this.utils.printWithType("Expected", expected, this.utils.printExpected)}`;
|
|
|
53
51
|
if (typeof expected === "string") {
|
|
54
52
|
printedExpected = `Expected${expectedSuffix}: not ${this.utils.printExpected(expected)}`;
|
|
55
53
|
if (!errorMessage) {
|
|
56
|
-
const formattedReceived = (0,
|
|
54
|
+
const formattedReceived = (0, import_utils.printReceivedStringContainExpectedSubstring)(this.utils, receivedString, receivedString.indexOf(expected), expected.length);
|
|
57
55
|
printedReceived = `Received${receivedSuffix}: ${formattedReceived}`;
|
|
58
56
|
}
|
|
59
57
|
} else {
|
|
60
58
|
printedExpected = `Expected${expectedSuffix}: not ${this.utils.printExpected(expected)}`;
|
|
61
59
|
if (!errorMessage) {
|
|
62
|
-
const formattedReceived = (0,
|
|
60
|
+
const formattedReceived = (0, import_utils.printReceivedStringContainExpectedResult)(this.utils, receivedString, typeof expected.exec === "function" ? expected.exec(receivedString) : null);
|
|
63
61
|
printedReceived = `Received${receivedSuffix}: ${formattedReceived}`;
|
|
64
62
|
}
|
|
65
63
|
}
|
|
@@ -70,10 +68,12 @@ ${this.utils.printWithType("Expected", expected, this.utils.printExpected)}`;
|
|
|
70
68
|
printedDiff = this.utils.printDiffOrStringify(expected, receivedString, `Expected${expectedSuffix}`, `Received${receivedSuffix}`, false);
|
|
71
69
|
}
|
|
72
70
|
const message = () => {
|
|
73
|
-
return (0,
|
|
71
|
+
return (0, import_utils.formatMatcherMessage)(this.utils, {
|
|
72
|
+
promise: this.promise,
|
|
73
|
+
isNot: this.isNot,
|
|
74
74
|
matcherName,
|
|
75
75
|
expectation: "expected",
|
|
76
|
-
locator,
|
|
76
|
+
locator: locator?.toString(),
|
|
77
77
|
timeout,
|
|
78
78
|
timedOut,
|
|
79
79
|
printedExpected,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/matchers/toMatchText.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nimport { expectTypes } from '../util';\nimport {\n printReceivedStringContainExpectedResult,\n printReceivedStringContainExpectedSubstring\n} from './expect';\nimport { formatMatcherMessage } from './matcherHint';\nimport { EXPECTED_COLOR } from '../common/expectBundle';\n\nimport type { MatcherResult } from './matcherHint';\nimport type { ExpectMatcherState } from '../../types/test';\nimport type { Page, Locator } from 'playwright-core';\n\nexport async function toMatchText(\n this: ExpectMatcherState,\n matcherName: string,\n receiver: Locator | Page,\n receiverType: 'Locator' | 'Page',\n query: (isNot: boolean, timeout: number) => Promise<{ matches: boolean, received?: string, log?: string[], timedOut?: boolean, errorMessage?: string }>,\n expected: string | RegExp,\n options: { timeout?: number, matchSubstring?: boolean } = {},\n): Promise<MatcherResult<string | RegExp, string>> {\n expectTypes(receiver, [receiverType], matcherName);\n const locator = receiverType === 'Locator' ? receiver as Locator : undefined;\n\n if (\n !(typeof expected === 'string') &&\n !(expected && typeof expected.test === 'function')\n ) {\n const errorMessage = `Error: ${EXPECTED_COLOR('expected')} value must be a string or regular expression\\n${this.utils.printWithType('Expected', expected, this.utils.printExpected)}`;\n throw new Error(formatMatcherMessage(this, { locator, matcherName, expectation: 'expected', errorMessage }));\n }\n\n const timeout = options.timeout ?? this.timeout;\n\n const { matches: pass, received, log, timedOut, errorMessage } = await query(!!this.isNot, timeout);\n\n if (pass === !this.isNot) {\n return {\n name: matcherName,\n message: () => '',\n pass,\n expected\n };\n }\n\n const expectedSuffix = typeof expected === 'string' ? (options.matchSubstring ? ' substring' : '') : ' pattern';\n const receivedSuffix = typeof expected === 'string' ? (options.matchSubstring ? ' string' : '') : ' string';\n const receivedString = received || '';\n let printedReceived: string | undefined;\n let printedExpected: string | undefined;\n let printedDiff: string | undefined;\n if (pass) {\n if (typeof expected === 'string') {\n printedExpected = `Expected${expectedSuffix}: not ${this.utils.printExpected(expected)}`;\n if (!errorMessage) {\n const formattedReceived = printReceivedStringContainExpectedSubstring(receivedString, receivedString.indexOf(expected), expected.length);\n printedReceived = `Received${receivedSuffix}: ${formattedReceived}`;\n }\n } else {\n printedExpected = `Expected${expectedSuffix}: not ${this.utils.printExpected(expected)}`;\n if (!errorMessage) {\n const formattedReceived = printReceivedStringContainExpectedResult(receivedString, typeof expected.exec === 'function' ? expected.exec(receivedString) : null);\n printedReceived = `Received${receivedSuffix}: ${formattedReceived}`;\n }\n }\n } else {\n if (errorMessage)\n printedExpected = `Expected${expectedSuffix}: ${this.utils.printExpected(expected)}`;\n else\n printedDiff = this.utils.printDiffOrStringify(expected, receivedString, `Expected${expectedSuffix}`, `Received${receivedSuffix}`, false);\n }\n\n const message = () => {\n return formatMatcherMessage(this, {\n matcherName,\n expectation: 'expected',\n locator,\n timeout,\n timedOut,\n printedExpected,\n printedReceived,\n printedDiff,\n log,\n errorMessage,\n });\n };\n\n return {\n name: matcherName,\n expected,\n message,\n pass,\n actual: received,\n log,\n timeout: timedOut ? timeout : undefined,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,kBAA4B;AAC5B,oBAGO;AACP,yBAAqC;AACrC,0BAA+B;AAM/B,eAAsB,YAEpB,aACA,UACA,cACA,OACA,UACA,UAA0D,CAAC,GACV;AACjD,+BAAY,UAAU,CAAC,YAAY,GAAG,WAAW;AACjD,QAAM,UAAU,iBAAiB,YAAY,WAAsB;AAEnE,MACE,EAAE,OAAO,aAAa,aACtB,EAAE,YAAY,OAAO,SAAS,SAAS,aACvC;AACA,UAAMA,gBAAe,cAAU,oCAAe,UAAU,CAAC;AAAA,EAAkD,KAAK,MAAM,cAAc,YAAY,UAAU,KAAK,MAAM,aAAa,CAAC;AACnL,UAAM,IAAI,UAAM,yCAAqB,MAAM,EAAE,SAAS,aAAa,aAAa,YAAY,cAAAA,cAAa,CAAC,CAAC;AAAA,EAC7G;AAEA,QAAM,UAAU,QAAQ,WAAW,KAAK;AAExC,QAAM,EAAE,SAAS,MAAM,UAAU,KAAK,UAAU,aAAa,IAAI,MAAM,MAAM,CAAC,CAAC,KAAK,OAAO,OAAO;AAElG,MAAI,SAAS,CAAC,KAAK,OAAO;AACxB,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,MAAM;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,OAAO,a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+
"names": ["errorMessage"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/browser/actions.d.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype Point = { x: number, y: number };\n\nexport type ActionName =\n 'check' |\n 'click' |\n 'closePage' |\n 'fill' |\n 'navigate' |\n 'openPage' |\n 'press' |\n 'select' |\n 'uncheck' |\n 'setInputFiles' |\n 'assertText' |\n 'assertValue' |\n 'assertChecked' |\n 'assertVisible' |\n 'assertSnapshot';\n\nexport type ActionBase = {\n name: ActionName,\n signals: Signal[],\n ariaSnapshot?: string,\n};\n\nexport type ActionWithSelector = ActionBase & {\n selector: string,\n ref?: string,\n screenshotFull?: {\n buffer: string;\n mimeType: string;\n timestamp: number;\n };\n screenshotElement?: {\n buffer: string;\n mimeType: string;\n timestamp: number;\n };\n};\n\nexport type ClickAction = ActionWithSelector & {\n name: 'click',\n button: 'left' | 'middle' | 'right',\n modifiers: number,\n clickCount: number,\n position?: Point,\n};\n\nexport type CheckAction = ActionWithSelector & {\n name: 'check',\n};\n\nexport type UncheckAction = ActionWithSelector & {\n name: 'uncheck',\n};\n\nexport type FillAction = ActionWithSelector & {\n name: 'fill',\n text: string,\n};\n\nexport type NavigateAction = ActionBase & {\n name: 'navigate',\n url: string,\n};\n\nexport type OpenPageAction = ActionBase & {\n name: 'openPage',\n url: string,\n};\n\nexport type ClosesPageAction = ActionBase & {\n name: 'closePage',\n};\n\nexport type PressAction = ActionWithSelector & {\n name: 'press',\n key: string,\n modifiers: number,\n};\n\nexport type SelectAction = ActionWithSelector & {\n name: 'select',\n options: string[],\n};\n\nexport type SetInputFilesAction = ActionWithSelector & {\n name: 'setInputFiles',\n files: string[],\n fullFiles?: {\n name: string,\n mimeType: string,\n buffer: string,\n lastModifiedMs?: number,\n }[],\n};\n\nexport type AssertTextAction = ActionWithSelector & {\n name: 'assertText',\n text: string,\n substring: boolean,\n};\n\nexport type AssertValueAction = ActionWithSelector & {\n name: 'assertValue',\n value: string,\n};\n\nexport type AssertCheckedAction = ActionWithSelector & {\n name: 'assertChecked',\n checked: boolean,\n};\n\nexport type AssertVisibleAction = ActionWithSelector & {\n name: 'assertVisible',\n};\n\nexport type AssertSnapshotAction = ActionWithSelector & {\n name: 'assertSnapshot',\n ariaSnapshot: string,\n};\n\nexport type Action = ClickAction | CheckAction | ClosesPageAction | OpenPageAction | UncheckAction | FillAction | NavigateAction | PressAction | SelectAction | SetInputFilesAction | AssertTextAction | AssertValueAction | AssertCheckedAction | AssertVisibleAction | AssertSnapshotAction;\nexport type AssertAction = AssertCheckedAction | AssertValueAction | AssertTextAction | AssertVisibleAction | AssertSnapshotAction;\nexport type PerformOnRecordAction = ClickAction | CheckAction | UncheckAction | PressAction | SelectAction;\n\n// Signals.\n\nexport type BaseSignal = {\n};\n\nexport type NavigationSignal = BaseSignal & {\n name: 'navigation',\n url: string,\n};\n\nexport type PopupSignal = BaseSignal & {\n name: 'popup',\n popupAlias: string,\n};\n\nexport type DownloadSignal = BaseSignal & {\n name: 'download',\n downloadAlias: string,\n};\n\nexport type DialogSignal = BaseSignal & {\n name: 'dialog',\n dialogAlias: string,\n};\n\nexport type Signal = NavigationSignal | PopupSignal | DownloadSignal | DialogSignal;\n\nexport type FrameDescription = {\n pageGuid: string;\n pageAlias: string;\n framePath: string[];\n};\n\nexport type ActionInContext = {\n frame: FrameDescription;\n description?: string;\n action: Action;\n startTime: number;\n endTime?: number;\n};\n\nexport type SignalInContext = {\n frame: FrameDescription;\n signal: Signal;\n timestamp: number;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|