Giter VIP home page Giter VIP logo

Comments (5)

AriPerkkio avatar AriPerkkio commented on August 16, 2024

What exactly is the use case for this?

  • Do you have test files that are listed in .gitignore and Vitest keeps running those tests?
  • Do you have source files that are listed in .gitignore and also imported by tests or other sources files, and changing those ignored files ends up re-running the tests?

from vitest.

sheremet-va avatar sheremet-va commented on August 16, 2024

If you want to have all files from .gitignore not be considered a test file (exclude option only affects test file glob matching), you can use parse-gitignore package:

import { configDefaults, defineConfig } from 'vitest/config'
import gitignore from 'parse-gitignore'
import { readFileSync } from 'node:fs'

export default defineConfig({
  test: {
    exclude: [
      ...configDefaults, 
      ...parse(readFileSync('.gitignore', 'utf-8')),
    ],
  },
})

from vitest.

charludo avatar charludo commented on August 16, 2024

What exactly is the use case for this?

* Do you have test files that are listed in `.gitignore` and Vitest keeps running those tests?

* Do you have source files that are listed in `.gitignore` and also imported by tests or other sources files, and changing those ignored files ends up re-running the tests?

The situation that prompted me to open this issue was that files inside .direnv are picked up by vitest. I'm not super familiar with direnv, but it appears that source files get linked/mirrored within it.

So instead of just testing

src/static/js/__tests__/my-file.test.ts`

vitest will also attempt to test

.direnv/flake-inputs/sidsuihfuefhb/src/static/js/__tests__/my-file.test.ts`

Since the direnv is already in .gitignore, it would have been nice if the folder got excluded automatically as well.

from vitest.

charludo avatar charludo commented on August 16, 2024

If you want to have all files from .gitignore not be considered a test file (exclude option only affects test file glob matching), you can use parse-gitignore package:

import { configDefaults, defineConfig } from 'vitest/config'
import gitignore from 'parse-gitignore'
import { readFileSync } from 'node:fs'

export default defineConfig({
  test: {
    exclude: [
      ...configDefaults, 
      ...parse(readFileSync('.gitignore', 'utf-8')),
    ],
  },
})

Oh, good idea, thank you!

from vitest.

sheremet-va avatar sheremet-va commented on August 16, 2024

.gitignore is not related to testing, so I don't think we can have a built-in switch. You can still use custom solutions as I mentioned.

from vitest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.