Jest.js 如何在vitest中抑制Vue的控制台警告?

9gm1akwq  于 2023-10-14  发布在  Jest
关注(0)|答案(1)|浏览(132)

在运行yarn test时,我面临着一些来自一些遗留组件的严重垃圾邮件,但我找不到解决来源的方法,那么有没有类似于jest的方法来抑制它?这个stack post展示了如何在jest中做到这一点,但在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= [...
pgccezyw

pgccezyw1#

你可以在vitest config中做同样的事情:

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

或直接在CLI中:

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

相关问题