|
| 1 | +# Getting started |
| 2 | +This guide is for developers who want to develop on Glean.js. |
| 3 | +## Prerequisites |
| 4 | +Glean.js uses [Node.js](https://nodejs.org/). |
| 5 | +Follow the [official guide](https://nodejs.dev/) to install it. |
| 6 | +### Version requirements |
| 7 | +* `node` >= 12.0.0 |
| 8 | +* `npm` >= 7.0.0 |
| 9 | + |
| 10 | +## Building Glean.js |
| 11 | +1. a terminal, navigate to the directory you want the Glean.js repository to live. Then: |
| 12 | +```bash |
| 13 | +git clone https://github.com/mozilla/glean.js |
| 14 | +``` |
| 15 | +2. navigate to the `glean` folder: |
| 16 | +```bash |
| 17 | +cd glean.js/glean |
| 18 | +``` |
| 19 | +3. Install all the node modules used by Glean.js: |
| 20 | +```bash |
| 21 | +npm install |
| 22 | +``` |
| 23 | + |
| 24 | +## Running tests |
| 25 | +Once you have [built](#building-gleanjs) Glean.js, run |
| 26 | +```bash |
| 27 | +npm run test |
| 28 | +``` |
| 29 | +in the `glean` folder. |
| 30 | + |
| 31 | +This runs all the tests in the `glean` folder. |
| 32 | +Alternatively, you may want to run component-specific tests. |
| 33 | +To do so, substitute `test` in the command above with one of the followings: |
| 34 | +* `test:core` - executes tests inside `tests/core` folder. |
| 35 | +* `test:plugins` - executes tests inside `tests/plugins` folder. |
| 36 | +* `test:platform` - executes tests inside `tests/platform` folder. |
| 37 | + |
| 38 | +You might want to run one specific test within a certain folder. |
| 39 | +To run the test with the title `DatetimeMetric` in the `core` folder: |
| 40 | +```bash |
| 41 | +npm run test:core -- --grep "DateTimeMetric" |
| 42 | +``` |
| 43 | +You should see the output similar to the following: |
| 44 | +```shell |
| 45 | + |
| 46 | +> @mozilla/glean@0.10.2 test:core |
| 47 | +> npm run test:base -- "tests/core/**/*.spec.ts" --recursive "--grep" "DatetimeMetric" |
| 48 | + |
| 49 | + |
| 50 | +> @mozilla/glean@0.10.2 test:base |
| 51 | +> node --experimental-modules --experimental-specifier-resolution=node --loader=ts-node/esm node_modules/mocha/lib/cli/cli.js "tests/core/**/*.spec.ts" "--recursive" "--grep" "DatetimeMetric" |
| 52 | + |
| 53 | +(node:52217) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time |
| 54 | +(Use `node --trace-warnings ...` to show where the warning was created) |
| 55 | + |
| 56 | + |
| 57 | + DatetimeMetric |
| 58 | + ✓ datetime internal representation validation works as expected |
| 59 | + ✓ attempting to get the value of a metric that hasn't been recorded doesn't error |
| 60 | + ✓ attempting to set when glean upload is disabled is a no-op |
| 61 | +Attempted to delete an entry from an invalid index. Ignoring. |
| 62 | +Attempted to delete an entry from an invalid index. Ignoring. |
| 63 | +Storage for deletion-request empty. Ping will still be sent. |
| 64 | +Attempted to delete an entry from an invalid index. Ignoring. |
| 65 | +Ping 053b739c-0b86-4032-ac45-29533d57ddc7 succesfully sent 200. |
| 66 | + ✓ ping payload is correct |
| 67 | + ✓ set properly sets the value in all pings |
| 68 | + ✓ truncation works |
| 69 | + ✓ get from different timezone than recording timezone keeps the original time intact |
| 70 | + |
| 71 | + |
| 72 | + 7 passing (27ms) |
| 73 | +``` |
0 commit comments