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

Removing mock-fs promises, rewriting mock async tests #501

Merged
merged 15 commits into from
Jul 30, 2021

Conversation

andrealit
Copy link
Collaborator

@andrealit andrealit commented Jul 29, 2021

Description:

After removing mock-fs from the project, remove any uses of mock-fs in the test cases and replace with mock-fs-promise. The two tests that need to be re-reviewed in the future after development are CanvasComponent.spec.tsx and Explorer.spec.tsx.

mock-fs-promise is an internal module that uses tmp-promise to create a temporary directory for holding all mocked filesystem objects (files, directories, and symbolic links). The API for mock-fs-promise mimics the API of mock-fs, but allows for consistent asynchronous access by depending on the standard Node.js fs (which natively supports Promises, callbacks, and async/await). Additionally, since mock-fs-promise is creating real files and directories, it is possible to create initialize a mocked directory as a valid git repository (see Git-Based Tests for an example of this).

This PR resolves #487, and signifies the following version changes:

  • MAJOR version increase
  • MINOR version increase
  • PATCH version increase

Changes:

This PR makes the following changes:

Checklist:

Before submitting this PR, I have verified that my code:

  • Resides on a fix/ or feature/ branch that was initially branched off from development.
  • Passes code linting (yarn lint) and unit testing (yarn test).
  • Successfully builds a distribution package (yarn package).

Additionally, I have verified that:

  • My name is listed in the Contributors section, or this PR includes a request to add my name.
  • I have read and am aware of the CONTRIBUTING guide for this project.

@andrealit andrealit linked an issue Jul 29, 2021 that may be closed by this pull request
4 tasks
Copy link
Member

@nelsonni nelsonni left a comment

Choose a reason for hiding this comment

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

Several items need to be addressed before this PR can be approved:

  • Update the .gitignore file to include the correct Yarn 2 exclusion rules (per inline comment).
  • Remove all of the .yarn/cache/*.zip and related files that would not be included based on the updated .gitignore rules.
  • Update package.json to not include @types/mock-fs or memfs (per inline comments).

@nelsonni nelsonni added bug Bug reports or bug fixes dependencies Issues or updates to dependency files feature Feature requests or improvements labels Jul 29, 2021
Copy link
Member

@nelsonni nelsonni left a comment

Choose a reason for hiding this comment

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

Two minor changes and then this PR is ready:

  • Remove .yarn/install-state.gz from git-tracking and don't include in the PR.
  • Remove the mock-fs import statement in __test__/CanvasComponent.spec.tsx

@nelsonni nelsonni added this to the v1.0.0 milestone Jul 30, 2021
nelsonni
nelsonni previously approved these changes Jul 30, 2021
@nelsonni
Copy link
Member

@andrealit, looks like you missed a mock-fs call in __test__/stacks.spec.ts:

FAIL __test__/stacks.spec.ts
  ● Test suite failed to run

    __test__/stacks.spec.ts:1:18 - error TS7016: Could not find a declaration file for module 'mock-fs'. '/home/runner/work/synectic/synectic/node_modules/mock-fs/lib/index.js' implicitly has an 'any' type.
      Try `npm i --save-dev @types/mock-fs` if it exists or add a new declaration (.d.ts) file containing `declare module 'mock-fs';`

    1 import mock from 'mock-fs';
                       ~~~~~~~~~

@andrealit andrealit merged commit 79b3f09 into development Jul 30, 2021
@andrealit andrealit deleted the feature/mock-fs-promise branch July 30, 2021 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports or bug fixes dependencies Issues or updates to dependency files feature Feature requests or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrating to Asynchronous Mocking for Tests
2 participants