w3resource

Yarn team and test CLI commands


In this tutorial we will show you how to manage team memberships, as well as how to run test scripts that are defined in your package.

Yarn team

The yarn team command is used to manage teams in organizations, it is also used to change team memberships.

Commands

yarn team create <scope:team>

When you run this command it will create a new team.

yarn team destroy <scope:team>

Running the command above will destroy an existing team.

yarn team add <scope:team> <user>

When you want to add a user to an existing team, you will need to run yarn team add <scope:team> <user>

yarn team remove <scope:team> <user>

When you want to remove a user from an existing team, you will need to run yarn team remove <scope:team> <user>

yarn team list <scope>|<scope:team>

When you perform this command on an organization name, it will return a list of the existing teams under that organization. If it is performed on a team, it will return a list of all users belonging to that particular team instead.

Details

Yarn will always operate directly on the current registry; this is configurable from the command line by running --registry=<registry url>.

If you want to create teams and manage a team's membership, you will have to be a team admin for that organization. Listing of teams and team memberships can be done by any member of the organizations.

The creation and management of team admins and organization members can only bedone from the npm website and not the CLI.

If you want to manage permissions on packages belonging to your organizations, you have to use the yarn access command grant or you revoke the appropriate permissions.

Yarn test

The yarn test command will run the test script that is defined by the package.

If you defined a scripts object in your package, it will run the specifies test script.

For instance, if you have a bash script that is in your package, scripts/test:

#!/bin/bash
echo "Hello, world!"
then, in your package.json file you could have:
```{
  "name": "my-example-package",
  "version": "1.0.0",
  "description":
    "This is just an example component",
  "main": "index.js",
  "author": "Yarn Contributor",
  "license": "MIT",
  "scripts": {
    "test": "scripts/test"
  }
}

Then when you run yarn test it will yield:

yarn test v1.2.1
$ "./scripts/test"
Hello, world!
Done in 0.17s.

yarn run test

yarn test is a shortcut for yarn run test.

Previous: Yarn tag
Next: Yarn unlink and yarn upgrade CLI commands



Follow us on Facebook and Twitter for latest update.