Search code examples
vue.jsunit-testingjestjsvuejs3vitest

How to suppress console warning from Vue in vitest?


I'm facing some serious spam from some legacy components while running yarn test but I can't find a way to resolve the source so is there a way to suppress it similar to jest? This stack post shows how to do it in jest but there seems to be no function like that in vitest.

[Vue warn]: injection "feathersClient" not found. 
  at <PriceCard key=0 price= {
  created: '2011-01-19T15:42:32.000+0100',
  updated: '2010-11-03T15:38:20.000+0100',
  id: 2720710,
  owner: { context: 1, user: 'root' },
  updater: { context: 1, user: 'root' },
  amount: 8.35,
  type: 'GROSS',
  currency: 'USD',
  period: { unit: 'MONTH', period: 12 },
  priceConditions: [ { configuration: [Object], condition: [Object] } ],
  nml: 'VGRS-PSIUSA',
  priority: 'DEFAULT',
  amountEur: 7.904953,
  amountUsd: 8.35,
  amountMinSalesEur: 8.300201,
  amountMinSalesUsd: 8.7675,
  product: {
    article: { type: 'domain', category: [Object], label: 'com' },
    id: 721,
    businessCase: 'renew'
  }
} onUpdate:price=fn<onUpdate:price>  ... > 
  at <SwimlanePrices> 
  at <DynamicScrollerItem item= {
  id: 'purchasePrices',
  priceRow: {
    nocondition: {
      create: [],
      createFee: [],
      renew: [],
      transfer: [],
      transferFee: [],
      restore: [],
      ownerchange: [],
      update: []
    },
    'W3siY29uZmlndXJhdGlvbiI6eyJmcm9tIjoiMjAxMi0wMS0xNVQwMDowMDowMC4wMDArMDEwMCJ9LCJjb25kaXRpb24iOnsibGFiZWwiOiJWQUxJRElUWSJ9fV0=': {
      create: [],
      createFee: [],
      renew: [Array],
      transfer: [],
      transferFee: [],
      restore: [],
      ownerchange: [],
      update: []
    },
    'W3siY29uZmlndXJhdGlvbiI6eyJmcm9tIjoiMjAwNy0wNi0xM1QwMDowMDowMC4wMDArMDIwMCJ9LCJjb25kaXRpb24iOnsibGFiZWwiOiJWQUxJRElUWSJ9fV0=': {
      create: [],
      createFee: [],
      renew: [],
      transfer: [],
      transferFee: [],
      restore: [Array],
      ownerchange: [],
      update: []
    },
    'W3siY29uZmlndXJhdGlvbiI6eyJmcm9tIjoiMjAwNy0wMS0xNlQwMDowMDowMC4wMDArMDEwMCJ9LCJjb25kaXRpb24iOnsibGFiZWwiOiJWQUxJRElUWSJ9fV0=': {
      create: [],
      createFee: [],
      renew: [],
      transfer: [Array],
      transferFee: [],
      restore: [],
      ownerchange: [],
      update: []
    },
    'W3siY29uZmlndXJhdGlvbiI6eyJmcm9tIjoiMjAwNy0wMS0xNVQwMDowMDowMC4wMDArMDEwMCJ9LCJjb25kaXRpb24iOnsibGFiZWwiOiJWQUxJRElUWSJ9fV0=': {
      create: [Array],
      createFee: [],
      renew: [],
      transfer: [],
      transferFee: [],
      restore: [],
      ownerchange: [Array],
      update: []
    }
  }
} active=true size-dependencies= [...

Solution

  • You could do the same thing in vitest config :

    
    export default defineConfig({
      test: {
        // ...
        silent : true
      },
    })
    

    or directly in CLI :

    "test:unit" : "vitest --silent"