Skip to content
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

Assert.file doesn't generate .husky files #36

Open
Daniele-Tentoni opened this issue May 10, 2024 · 1 comment
Open

Assert.file doesn't generate .husky files #36

Daniele-Tentoni opened this issue May 10, 2024 · 1 comment

Comments

@Daniele-Tentoni
Copy link

I'm using yeoman-test and yeoman-assert in my project to generate a template for vue. I wanna install husky for the user and init it after install. My repo is here https://gitlab.com/danieletentoni/generator-vite-vuetify. In my local env, I've linkend my project and I can generate the project, with husky and init it.

In my unit tests, I'm running my generator to install husky. But when I [run(https://gitlab.com/danieletentoni/generator-vite-vuetify/-/blob/main/tests/app.spec.js?ref_type=heads#L31):

.then(function (dir) {
        console.log("DIR: ", dir.cwd);
        console.log(fs.readdirSync(dir.cwd));
        assert.fileContent("README.md", /# test/);
        assert.fileContent(".husky/pre-commit", "npm test");
      });

No .husky and .git folders are found. In the test directory, those files, are discarded? The temporary file system doesn't manage them?

@JoshuaKGoldberg
Copy link

JoshuaKGoldberg commented Jan 24, 2025

🤔 I'm not following exactly what's being asked for here. Assert.file wouldn't generate any files, it just would test that they exist. Is that a typo? As in, are you asking why the tplFiles inside the generator's writing() aren't being found in tests, despite apparently being written to disk?

Also, after a git clone and npm install on that repository, I get a failure in an unrelated test:

  App template
    1) Contains README with app name
DIR:  /private/var/folders/sr/j__6_9gn0dv557z0xf3p7y8h0000gn/T/c15583c7123c4f364b9e86d5ae6c093d48ead4eb
[ 'test' ]
    ✔ contains husky


  1 passing (257ms)
  1 failing

  1) App template
       Contains README with app name:

      AssertionError [ERR_ASSERTION]: test-app/package.json did not match '/"name": "test-app"/'. Contained:

{
  "version": "0.0.0",
  "private": true,
  "type": "module",
  ... (omitted from GH comment for brevity)
    "vitest": "^1.4.0",
    "vue-tsc": "^2.0.11"
  }
}

      + expected - actual

      -false
      +true
      
      at /Users/josh/repos/generator-vite-vuetify/node_modules/yeoman-assert/index.js:115:5
      at Array.forEach (<anonymous>)
      at assert.fileContent (node_modules/yeoman-assert/index.js:102:26)
      at file:///Users/josh/repos/generator-vite-vuetify/__tests__/app.spec.js:25:16

@Daniele-Tentoni could you please post a full set of steps we can run to see what you're seeing? As in, an isolated reproduction or instructions to make one (https://antfu.me/posts/why-reproductions-are-required)? We'd be happy to take a look then. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants