Skip to content

feat(coverage): support --changed option #5314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Feb 29, 2024

Description

I think I'll leave this part out of this PR now: #5237 (comment). That requires some discussion as it changes functionality of --changed quite much.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Feb 29, 2024

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit 8761e80
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65e456b4aee76f0008c9fb5e
😎 Deploy Preview https://deploy-preview-5314--fastidious-cascaron-4ded94.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines -270 to -275
// Make sure file is not served from cache
// so that instrumenter loads up requested file coverage
if (this.ctx.vitenode.fetchCache.has(filename))
this.ctx.vitenode.fetchCache.delete(filename)

await this.ctx.vitenode.transformRequest(filename)
Copy link
Member Author

@AriPerkkio AriPerkkio Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this wasn't working as I expected it to. Files were served from Vite's cache when vite-node's fetchCache was cleared. This came up only with --changed flag as core.ts already loaded those files.

Minimal repro using vite-node:

import { createServer } from "vite";
import { ViteNodeServer } from "vite-node/server";

const server = await createServer({
  plugins: [
    {
      name: "logger",
      transform(code, id) {
        console.log(`[transform] ${id}`);
      },
    },
  ],
});
await server.pluginContainer.buildStart({});

const node = new ViteNodeServer(server);

// Should log [transform] ✅ 
console.log("transformRequest #1");
await node.transformRequest("./example.ts");


// Should log NOT [transform] ✅ 
console.log("transformRequest #2");
await node.transformRequest("./example.ts");

// Should log [transform] but it doesn't ❌ 
console.log("transformRequest #3");
node.fetchCache.clear();
node.fetchCaches.ssr.clear();
node.fetchCaches.web.clear();
await node.transformRequest("./example.ts");

node.server.close();

@AriPerkkio AriPerkkio force-pushed the feat/coverage-with-changed branch 4 times, most recently from ddf24af to 149714f Compare March 3, 2024 10:49
@AriPerkkio AriPerkkio force-pushed the feat/coverage-with-changed branch from 149714f to 8761e80 Compare March 3, 2024 10:53
@AriPerkkio AriPerkkio marked this pull request as ready for review March 3, 2024 10:53
@sheremet-va sheremet-va added this to the 1.4.0 milestone Mar 5, 2024
@sheremet-va sheremet-va merged commit 600b44d into vitest-dev:main Mar 14, 2024
@AriPerkkio AriPerkkio deleted the feat/coverage-with-changed branch March 14, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coverage with Changed
2 participants