Skip to content

Commit

Permalink
chore: revert debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 22, 2023
1 parent ba407df commit ef3d07e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
8 changes: 1 addition & 7 deletions packages/snapshot/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export class SnapshotClient {
constructor(private options: SnapshotClientOptions = {}) {}

async startCurrentRun(filepath: string, name: string, options: SnapshotStateOptions) {
console.log("[SnapshotClient.startCurrentRun]", { filepath, name });

this.filepath = filepath
this.name = name

Expand All @@ -70,7 +68,7 @@ export class SnapshotClient {
const created = await SnapshotState.create(
filepath,
options,
);
)
if (!this.getSnapshotState(filepath)) {
this.snapshotStateMap.set(
filepath,
Expand All @@ -95,8 +93,6 @@ export class SnapshotClient {
}

assert(options: AssertOptions): void {
console.log("[SnapshotClient.assert:in]", options);

const {
filepath = this.filepath,
name = this.name,
Expand Down Expand Up @@ -146,7 +142,6 @@ export class SnapshotClient {
inlineSnapshot,
rawSnapshot,
})
console.log("[SnapshotClient.assert:out]", { actual, expected, key, pass });

if (!pass)
throw createMismatchError(`Snapshot \`${key || 'unknown'}\` mismatched`, this.snapshotState?.expand, actual?.trim(), expected?.trim())
Expand Down Expand Up @@ -181,7 +176,6 @@ export class SnapshotClient {
if (!this.snapshotState)
return null
const result = await this.snapshotState.pack()
console.log("[SnapshotClient.finishCurrentRun]", result);

this.snapshotState = undefined
return result
Expand Down
13 changes: 0 additions & 13 deletions packages/snapshot/src/port/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export default class SnapshotState {
testFilePath: string,
options: SnapshotStateOptions,
) {
console.log("[SnapshotState.create]", { testFilePath });
const snapshotPath = await options.snapshotEnvironment.resolvePath(testFilePath)
const content = await options.snapshotEnvironment.readSnapshotFile(snapshotPath)
return new SnapshotState(testFilePath, snapshotPath, content, options)
Expand Down Expand Up @@ -228,15 +227,6 @@ export default class SnapshotState {
error,
rawSnapshot,
}: SnapshotMatchOptions): SnapshotReturnOptions {
console.log("[SnapshotState.match]", {
testName,
received,
key,
inlineSnapshot,
isInline,
error,
rawSnapshot
});
this._counters.set(testName, (this._counters.get(testName) || 0) + 1)
const count = Number(this._counters.get(testName))

Expand Down Expand Up @@ -271,7 +261,6 @@ export default class SnapshotState {
const pass = expectedTrimmed === prepareExpected(receivedSerialized)
const hasSnapshot = expected !== undefined
const snapshotIsPersisted = isInline || this._fileExists || (rawSnapshot && rawSnapshot.content != null)
console.log("[SnapshotState.match:2]", { expected, pass, hasSnapshot, snapshotIsPersisted }, [this._updateSnapshot]);

if (pass && !isInline && !rawSnapshot) {
// Executing a snapshot file as JavaScript and writing the strings back
Expand Down Expand Up @@ -309,7 +298,6 @@ export default class SnapshotState {
}
}
else {
console.log("@@@@@@@ this.added++")
this._addSnapshot(key, receivedSerialized, { error, isInline, rawSnapshot })
this.added++
}
Expand Down Expand Up @@ -337,7 +325,6 @@ export default class SnapshotState {
}
}
else {
console.log("@@@@@@@ this.matched++")
this.matched++
return {
actual: '',
Expand Down
17 changes: 5 additions & 12 deletions test/core/test/repro.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { it, beforeAll } from 'vitest';

// a little trick to restore normal console.log to see genuine chronological order
// https://github.com/vitest-dev/vitest/issues/1405#issuecomment-1858696036
// beforeAll(async () => {
// const { Console } = await import("node:console");
// globalThis.console = new Console(process.stdout, process.stderr);
// });
import { it } from 'vitest'

it.concurrent('1st', ({ expect }) => {
expect("hi1").toMatchInlineSnapshot(`"hi1"`);
});
expect('hi1').toMatchInlineSnapshot(`"hi1"`)
})

it.concurrent('2nd', ({ expect }) => {
expect("hi2").toMatchInlineSnapshot(`"hi2"`);
});
expect('hi2').toMatchInlineSnapshot(`"hi2"`)
})

0 comments on commit ef3d07e

Please sign in to comment.