(options: AssertDomainOptions)
| 212 | } |
| 213 | |
| 214 | matchDomain(options: AssertDomainOptions): MatchResult { |
| 215 | const { |
| 216 | received, |
| 217 | filepath, |
| 218 | name, |
| 219 | testId = name, |
| 220 | message, |
| 221 | adapter, |
| 222 | isInline = false, |
| 223 | inlineSnapshot, |
| 224 | error, |
| 225 | } = options |
| 226 | |
| 227 | if (!filepath) { |
| 228 | throw new Error('Snapshot cannot be used outside of test') |
| 229 | } |
| 230 | |
| 231 | const captured = adapter.capture(received) |
| 232 | const rendered = adapter.render(captured) |
| 233 | |
| 234 | const snapshotState = this.getSnapshotState(filepath) |
| 235 | const testName = [name, ...(message ? [message] : [])].join(' > ') |
| 236 | |
| 237 | const expectedSnapshot = snapshotState.probeExpectedSnapshot({ |
| 238 | testName, |
| 239 | testId, |
| 240 | isInline, |
| 241 | inlineSnapshot, |
| 242 | }) |
| 243 | expectedSnapshot.markAsChecked() |
| 244 | const matchResult = expectedSnapshot.data |
| 245 | ? adapter.match(captured, adapter.parseExpected(expectedSnapshot.data)) |
| 246 | : undefined |
| 247 | const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({ |
| 248 | testId, |
| 249 | received: rendered, |
| 250 | expectedSnapshot, |
| 251 | matchResult, |
| 252 | isInline, |
| 253 | error, |
| 254 | assertionName: options.assertionName, |
| 255 | }) |
| 256 | |
| 257 | return { |
| 258 | pass, |
| 259 | message: () => `Snapshot \`${key}\` mismatched`, |
| 260 | actual: actual?.trim(), |
| 261 | expected: expected?.trim(), |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | async pollMatchDomain(options: AssertDomainPollOptions): Promise<MatchResult> { |
| 266 | const { |
no test coverage detected