How to use the bs-logger.testing.createLoggerMock function in bs-logger

To help you get started, we’ve selected a few bs-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kulshekhar / ts-jest / src / transformers / hoist-jest.spec.ts View on Github external
console.log(bar)
  jest.unmock('./foo')
  jest.mock('./bar')
  jest.mock('./bar/foo', () => 'foo')
  jest.unmock('./foo/bar')
}
const func2 = () => {
  const bar = 'bar'
  console.log(bar)
  jest.mock('./bar')
  jest.unmock('./foo/bar')
  jest.mock('./bar/foo', () => 'foo')
  jest.unmock('./foo')
}
`
const logger = testing.createLoggerMock()
const createFactory = () => {
  return hoist.factory({ logger, compilerModule: tsc } as any)
}
const transpile = (source: string) => tsc.transpileModule(source, { transformers: { before: [createFactory()] } })

describe('hoisting', () => {
  it('should have correct signature', () => {
    expect(hoist.name).toBe('hoisting-jest-mock')
    expect(typeof hoist.version).toBe('number')
    expect(hoist.version).toBeGreaterThan(0)
    expect(typeof hoist.factory).toBe('function')
  })

  it('should hoist jest mock() and unmock() statements', () => {
    const out = transpile(CODE_WITH_HOISTING)
    expect(out.outputText).toMatchInlineSnapshot(`
github kulshekhar / ts-jest / src / config / config-set.spec.ts View on Github external
describe('raiseDiagnostics', () => {
  const createTsError = jest.fn(
    (list: Diagnostic[]) => new Error(list.map(d => `[TS${d.code}] ${d.messageText}`).join('\n')),
  )
  const filterDiagnostics = jest.fn(list => list)
  const logger = testing.createLoggerMock()
  const makeDiagnostic = ({
    messageText = 'foo',
    code = 9999,
    category = DiagnosticCategory.Warning,
  }: Partial = {}): Diagnostic => ({ messageText, code, category } as any)
  it('should throw when warnOnly is false', () => {
    const { raiseDiagnostics } = createConfigSet({ createTsError, filterDiagnostics })
    expect(() => raiseDiagnostics([])).not.toThrow()
    expect(() => raiseDiagnostics([makeDiagnostic()])).toThrowErrorMatchingInlineSnapshot(`"[TS9999] foo"`)
    expect(() => raiseDiagnostics([makeDiagnostic({ category: DiagnosticCategory.Message })])).not.toThrow()
  })
  it('should not throw when warnOnly is true', () => {
    const { raiseDiagnostics } = createConfigSet({
      createTsError,
      filterDiagnostics,
      logger,
github kulshekhar / ts-jest / src / util / backports.spec.ts View on Github external
import { testing } from 'bs-logger'
import set = require('lodash.set')
import { inspect } from 'util'

import { backportJestConfig } from './backports'

const logger = testing.createLoggerMock()
const logTarget = logger.target

beforeEach(() => {
  logTarget.clear()
})

describe('backportJestConfig', () => {
  const makeTestsFor = (oldPath: string, _: string, values: any[]) => {
    values.forEach(val => {
      let original: any
      beforeEach(() => {
        original = {}
        set(original, oldPath, val)
      })
      describe(`with "${oldPath}" set to ${inspect(val)}`, () => {
        it(`should wran the user`, () => {