jpedro73
jpedro73
NNuxt
Created by jpedro73 on 2/28/2025 in #❓・help
Hi! How to mockup multiples pinia stores?
I have this ts file that export a fn and this auxiliar fn uses two pinia stores, the "useProductionStore()"and the "useGlobalStore()":
import type { ItemConvertedToActs } from '@/types/productions/summarySection'
import type { RersourceResultType, PieData, PieLabels, ConvertedEqItemType, NonWorkItemType, ConvertedHrItemType, AcivitiesSummaryData } from '@/types/components/productions/typesComponentsProductionsSummary'
import type { ActiviTyStatistcsType } from '@/types/resourcesTypes.ts'

const productionStore = useProductionStore()
const globalStore = useGlobalStore()

export function getActivitiesStatistics(acivitiesSummaryData: AcivitiesSummaryData): ActiviTyStatistcsType[] {
console.time('getActivitiesStatistics')
...
for (let i = 0; i < activitiesStatisticsWithActCode.length; i++) {
...
const actDataArrayByType = **productionStore**.activitiesTabData[statisticItem.actType]
...
}
const newItem: ActiviTyStatistcsWithActCode = {
'actCode': actItem.actCode,
'center': globalStore.pickedCenter.code!,
...
}
}
}
import type { ItemConvertedToActs } from '@/types/productions/summarySection'
import type { RersourceResultType, PieData, PieLabels, ConvertedEqItemType, NonWorkItemType, ConvertedHrItemType, AcivitiesSummaryData } from '@/types/components/productions/typesComponentsProductionsSummary'
import type { ActiviTyStatistcsType } from '@/types/resourcesTypes.ts'

const productionStore = useProductionStore()
const globalStore = useGlobalStore()

export function getActivitiesStatistics(acivitiesSummaryData: AcivitiesSummaryData): ActiviTyStatistcsType[] {
console.time('getActivitiesStatistics')
...
for (let i = 0; i < activitiesStatisticsWithActCode.length; i++) {
...
const actDataArrayByType = **productionStore**.activitiesTabData[statisticItem.actType]
...
}
const newItem: ActiviTyStatistcsWithActCode = {
'actCode': actItem.actCode,
'center': globalStore.pickedCenter.code!,
...
}
}
}
My test file:
import { it, expect, describe, test, vi } from 'vitest'
import { mockNuxtImport, mountSuspended } from '@nuxt/test-utils/runtime'
import storeProd from './data/productionStore.json'
...

mockNuxtImport('useProductionStore', () => {
return () => {
return storeProd
}
})
describe('getAcivitiesSummaryData', () => {
test('returns an object with effectiveWorkData and nonWorkData', async () => {
const result = getActivitiesStatistics(acivitiesSummaryData)
console.log(result);
expect(result).toBeDefined()
expect(result).toHaveProperty('effectiveWorkData');
expect(result).toHaveProperty('nonWorkData');
expect(result).toHaveProperty('pieDataEffectiveWork')
})
})
import { it, expect, describe, test, vi } from 'vitest'
import { mockNuxtImport, mountSuspended } from '@nuxt/test-utils/runtime'
import storeProd from './data/productionStore.json'
...

mockNuxtImport('useProductionStore', () => {
return () => {
return storeProd
}
})
describe('getAcivitiesSummaryData', () => {
test('returns an object with effectiveWorkData and nonWorkData', async () => {
const result = getActivitiesStatistics(acivitiesSummaryData)
console.log(result);
expect(result).toBeDefined()
expect(result).toHaveProperty('effectiveWorkData');
expect(result).toHaveProperty('nonWorkData');
expect(result).toHaveProperty('pieDataEffectiveWork')
})
})
My test file works well, but i can't find the way to mockup the other pinia store "useGlobalStore()"
9 replies
NNuxt
Created by jpedro73 on 8/4/2023 in #❓・help
Error cannot find module - new nuxt3 app
Hi! I've updated my node version, from the 18.14.0 to the 18.17.0 and all my nuxt apps stops responding. Afer i tried to install a new fresh nuxt3 app, and identical error. The errors are like: ERROR Error while requiring module C:/Program Files/nodejs/node_modules/@nuxt/devtools/module.cjs: Error: Cannot find module 'C:/Program Files/nodejs/node_modules/@nuxt/devtools/module.cjs' 19:55:42
Require stack: - C:\Users\jpedr\nuxt3C\index.js Some case are the devtools other are other modules, but what is strange, is the path...all cases are looking in the folder where nodejs is installed...the "Program Files" folder instead of the folder of the app, inside the node_modules, right? I've unnistalled nvm, yarn, pnpm and nodeJS and installed just one of them, but always the same kind of error, please someone help me. Note; If i'm using node 18.14.0, some nuxt3 app work fine, but whatever the version of nodejs I can't install a new nuxt3 app.
2 replies
NNuxt
Created by jpedro73 on 4/22/2023 in #❓・help
Multiple errors after updated from nuxt 3.4.1 to 3.4.2
No description
15 replies
NNuxt
Created by jpedro73 on 3/14/2023 in #❓・help
Export from json to excel in nuxt3?
Anyone can recommend a package or module to export from json to excel or csv, directly from the browser in Nuxt3?
7 replies