Skip to content

test(cli): migrate from memfs mock to fs-fixture #457

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

Closed
wants to merge 6 commits into from
Closed

Conversation

ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Jun 2, 2025

Migrate from memfs to fs-fixture because it is more intuitive!

https://github.com/privatenumber/fs-fixture/tree/master

@ryoppippi ryoppippi requested a review from Copilot June 2, 2025 20:58
@ryoppippi ryoppippi changed the title test(cli): remove memfs mock test(cli): migrate from memfs mock to fs-fixture Jun 2, 2025
Copilot

This comment was marked as outdated.

Copy link

pkg-pr-new bot commented Jun 2, 2025

Open in StackBlitz

@agentica/benchmark

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/benchmark@457

@agentica/chat

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/chat@457

agentica

npm i https://pkg.pr.new/wrtnlabs/agentica@457

@agentica/core

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/core@457

create-agentica

npm i https://pkg.pr.new/wrtnlabs/agentica/create-agentica@457

@agentica/rpc

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/rpc@457

@agentica/vector-selector

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/vector-selector@457

commit: 6efb9b8

@ryoppippi ryoppippi marked this pull request as draft June 2, 2025 21:05
@ryoppippi
Copy link
Contributor Author

too freaky...

@ryoppippi
Copy link
Contributor Author

OK so this is because the template is updated to openai5, while this repo still using openai sdk 4

@ryoppippi
Copy link
Contributor Author

fixed nestia template.
now it works

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Migrate tests in the CLI package from using memfs to fs-fixture for more intuitive filesystem fixtures and bump test concurrency.

  • Added maxConcurrency setting to Vitest config.
  • Replaced memfs mocks and APIs in tests with fs-fixture.
  • Updated package.json to remove memfs and add fs-fixture, and removed manual __mocks__ files.

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vitest.config.mts Increased test runner concurrency with maxConcurrency: 10.
src/fs.test.ts Swapped out memfs usage for fs-fixture in unit tests.
src/commands/start.test.ts Converted integration tests to use fs-fixture and removed manual tmp dir logic.
package.json Removed memfs dependency and added fs-fixture.
mocks/fs/promises.cjs & fs.cjs Removed legacy memfs mock files.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

describe("setupStandAloneProject", () => {
it("should create a new directory and set project .env file", async () => {
const destinationDirectory = resolve(tmpParentDirectory, ".tmp/standalone");
/** create a fixture */
await using fixture = await createFixture();
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent fixture cleanup: some tests use await using while others use a plain const fixture = await createFixture() without automatic disposal. Consider standardizing on one pattern so resources are managed uniformly.

Copilot uses AI. Check for mistakes.

Comment on lines 36 to +37
// check if the directory exists
expect(existsSync(destinationDirectory)).toBe(true);
expect(existsSync(resolve(destinationDirectory, "package.json"))).toBe(true);
expect(await fixture.exists()).toBe(true);
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

This assertion only verifies that the fixture root directory (created by createFixture) exists by default. It doesn't confirm that the command actually generated the intended project files—assert on specific paths or files instead (e.g. fixture.exists('package.json')).

Copilot uses AI. Check for mistakes.

const content = vol.readFileSync("/my-new-project/.env", "utf-8");

expect(content).toBe("OPENAI_API_KEY=sk-foo");
expect (await fixture.readFile(".env", "utf-8")).toBe("OPENAI_API_KEY=sk-foo");
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Remove the space between expect and the opening parenthesis for consistent test styling: use expect(await fixture.readFile(...)).

Suggested change
expect (await fixture.readFile(".env", "utf-8")).toBe("OPENAI_API_KEY=sk-foo");
expect(await fixture.readFile(".env", "utf-8")).toBe("OPENAI_API_KEY=sk-foo");

Copilot uses AI. Check for mistakes.

@ryoppippi ryoppippi closed this Jun 14, 2025
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.

1 participant