Skip to content

Commit

Permalink
fix(testing): change logging level for some utility
Browse files Browse the repository at this point in the history
  • Loading branch information
huafu committed Sep 2, 2018
1 parent 254d36e commit 16f125a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 892 deletions.
166 changes: 0 additions & 166 deletions e2e/__tests__/__snapshots__/logger.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,16 @@ Array [
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] readFile",
"[level:20] readFile",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] computing cache key for <cwd>/Hello.ts",
"[level:20] processing <cwd>/Hello.ts",
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
]
`;
Expand Down Expand Up @@ -107,51 +73,17 @@ Array [
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] readFile",
"[level:20] readFile",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] calling babel-jest processor",
"[level:20] computing cache key for <cwd>/Hello.ts",
"[level:20] processing <cwd>/Hello.ts",
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] calling babel-jest processor",
]
Expand Down Expand Up @@ -190,51 +122,17 @@ Array [
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] readFile",
"[level:20] readFile",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] calling babel-jest processor",
"[level:20] computing cache key for <cwd>/Hello.ts",
"[level:20] processing <cwd>/Hello.ts",
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] calling babel-jest processor",
]
Expand Down Expand Up @@ -264,50 +162,16 @@ Array [
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] readFile",
"[level:20] readFile",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] computing cache key for <cwd>/Hello.ts",
"[level:20] processing <cwd>/Hello.ts",
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
]
`;
Expand Down Expand Up @@ -337,46 +201,16 @@ Array [
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] readFile",
"[level:20] readFile",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] getScriptSnapshot(): cache miss",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
"[level:20] computing cache key for <cwd>/Hello.ts",
"[level:20] processing <cwd>/Hello.ts",
"[level:20] readThrough(): cache miss",
"[level:20] getOutput(): compiling using language service",
"[level:20] updateMemoryCache()",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] visitSourceFileNode(): hoisting",
"[level:20] getOutput(): computing diagnostics",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] getScriptSnapshot(): cache hit",
"[level:20] readThrough(): writing caches",
]
`;
Expand Down
11 changes: 7 additions & 4 deletions e2e/__tests__/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { configureTestCase } from '../__helpers__/test-case'
import { PackageSets, allValidPackageSets } from '../__helpers__/templates'
import { existsSync } from 'fs'
import { LogContexts } from 'bs-logger'
import { LogContexts, LogLevels } from 'bs-logger'

describe('With unsupported version test', () => {
const testCase = configureTestCase('simple')
Expand All @@ -23,9 +23,12 @@ describe('TS_JEST_LOG', () => {
const result = runTest()
expect(result.status).toBe(0)
expect(existsSync(result.logFilePath))
expect(result.logFileEntries.map(
e => result.normalize(`[level:${e.context[LogContexts.logLevel]}] ${e.message}`),
)).toMatchSnapshot()
const filteredEntries = result.logFileEntries
// keep only debu and above
.filter(m => (m.context[LogContexts.logLevel] || 0) >= LogLevels.debug)
// simplify entires
.map(e => result.normalize(`[level:${e.context[LogContexts.logLevel]}] ${e.message}`))
expect(filteredEntries).toMatchSnapshot()
})
})
})
Loading

0 comments on commit 16f125a

Please sign in to comment.