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

Allow to replace files with other (mock) ones #25

Open
DmitrySharabin opened this issue Apr 6, 2024 · 0 comments
Open

Allow to replace files with other (mock) ones #25

DmitrySharabin opened this issue Apr 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@DmitrySharabin
Copy link
Collaborator

In Madata, we have a natively supported Firebase backend. However, we face an issue when we need to test it (or any other Madata feature depending on this backend, e.g., the Backend.from() method) in Node. The Firebase backend imports the modules it depends on (provided by Google) via URLs with the https scheme, which Node's default ESM loader does not support.

It would be nice if hTest could provide a way to replace one file (e.g., by intercepting the corresponding request) with another one on the fly. For example, we could provide hTest a mock Firebase backend (with the functionality we need to test) instead of the real one. This feature will allow hTest to avoid choking over features unsupported by Node (or any other environment the tests run in).

This enhancement might also be helpful in other cases, such as when we need to test features requiring some user actions, like authentication.

As another option, hTest might support something similar to Angular's Dependency Injection, where the author can use some existing class instead of the injected one. If I'm correct, this feature is heavily used exactly when some class (component, directive, etc.) needs to be tested, and it depends on a (injected) class that is replaced by another (mock) class.

In other words, it would be helpful if hTest supports something like (unsure about the API, just an example):

export default {
	replace: {
		"./src/foo.js": "./test/foo.js",
	},
	tests: [...],
};

OR

export default {
	use: {
		"./src/foo.js": "./test/foo.js",
	},
	tests: [...],
};
@DmitrySharabin DmitrySharabin added the enhancement New feature or request label Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant