'vitetest: Failed to resolve import "$lib/stores/store"

tried running tests with vitest and it can seem to resolve dependencies from $lib/* and $app/* this is the error, Failed to resolve import "$lib/stores/store" from "src/lib/components/Hello.svelte". Does the file exist? here is the link to the playground https://gitlab.com/paulwvnjohi/hello-vitest enter image description here



Solution 1:[1]

It seems Vitest is NOT automatically picking up your Vite config, since it's "hidden" in svelte.config.js and I'm sure there's tons of magic stuff SvelteKit adds, such as the resolve.alias paths for things like the $lib and $app imports to work.

I don't know if Vitest core would do something automatically in the future, but now there's the vitest-svelte-kit package you can use: https://github.com/nickbreaton/vitest-svelte-kit

Install the package:

npm i -D vitest-svelte-kit

Create a file vitest.config.js and put inside the method that magically extracts the correct vite config for you, according to your settings in svelte.config.js:

// vitest.config.js
import { extractFromSvelteConfig } from "vitest-svelte-kit"

export default extractFromSvelteConfig()

Worked for me!

Solution 2:[2]

You code seems good for me except the set-aduser you need to replace $csv with $line

Import-Module ActiveDirectory 
$csv = Import-Csv C:\Temp\AD_import_test.csv 
foreach ($line in $csv) {
$displayName = $line.displayName
Get-ADUser -Filter {displayName -eq $displayName} |
Set-ADUser -Title $($line.title) -department $($line.Department) -physicalDeliveryOfficeName $($line.physicalDeliveryOfficeName) }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Johnny Magrippis
Solution 2 Mahmoud Moawad