Skip to content

chore: improve unit tests #4397

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
Feb 26, 2019
Merged

Conversation

rosen-vladimirov
Copy link
Contributor

chore: rewrite create project tests

There are some extremely slow integration tests for project creation. They mock the prompter and try to validate different use-cases when user enters invalid name and CLI prompts for correct name.
However, this is already handled in project-name-service tests. So, remove the slow integration tests for project creation and replace them with unit tests that ensure the project creation will fail in case projectNameService fails.

chore: rewrite npm support tests

There are 4 tests marked as npm support tests, which are in fact e2e tests - they create project, add dependencies and prepare the project. These tests are executed for around 1 minute.
Rewrite them as unit tests, so they take around 20ms now.

PR Checklist

What is the current behavior?

Unit tests are executed for 5-7 minutes

What is the new behavior?

Unit tests are executed for 1:00-1:30 minutes

There are 4 tests marked as `npm support tests`, which are in fact e2e tests - they create project, add dependencies and prepare the project. These tests are executed for around 1 minute.
Rewrite them as unit tests, so they take around 20ms now.
There are some extremely slow integration tests for project creation. They mock the prompter and try to validate different use-cases when user enters invalid name and CLI prompts for correct name.
However, this is already handled in `project-name-service` tests. So, remove the slow integration tests for project creation and replace them with unit tests that ensure the project creation will fail in case projectNameService fails.
@cla-bot cla-bot bot added the cla: yes label Feb 26, 2019
@ghost ghost added new PR and removed cla: yes labels Feb 26, 2019
@@ -58,10 +59,11 @@ describe("nodeModulesDependenciesBuilder", () => {
return path.join(parentDir || pathToProject, constants.NODE_MODULES_FOLDER_NAME, dependencyName);
};

const getNodeModuleInfoForExpecteDependency = (name: string, depth: number, nativescript?: any, dependencies?: string[]): IDependencyData => {
const getNodeModuleInfoForExpecteDependency = (dir: string, depth: number, nativescript?: any, dependencies?: string[], name?: string): IDependencyData => {
Copy link
Contributor

Choose a reason for hiding this comment

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

getNodeModuleInfoForExpectedDependency

@rosen-vladimirov rosen-vladimirov merged commit 55c01b9 into release Feb 26, 2019
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/improve-unit-tests branch February 26, 2019 11:22
@ghost ghost removed the new PR label Feb 26, 2019
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.

4 participants