Skip to content

Commit

Permalink
Merge pull request #3 from bodo-run/e2e
Browse files Browse the repository at this point in the history
Node.js E2E
  • Loading branch information
mohsen1 authored Jan 17, 2025
2 parents 070f5e3 + 25ccce9 commit 2106e3b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 4 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,3 @@ You'll see these warnings in the console logs, but your process will exit **0**
If an environment variable is **already set**, `stop-nagging` **does not override** it. This avoids unintentional conflicts with variables you may want set differently. If a var is already set, we print a warning like:

Warning: Env var 'KEY' is already set; skipping override for tool 'npm'.

```
```
47 changes: 47 additions & 0 deletions tests/node_e2e_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use assert_cmd::Command;
use predicates::prelude::*;
use std::error::Error;
use std::path::PathBuf;

#[test]
fn test_nodejs_ecosystem_e2e() -> Result<(), Box<dyn Error>> {
let node_e2e_yaml = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("test_files")
.join("node_e2e.yaml");

let mut cmd = Command::cargo_bin("stop-nagging")?;
cmd.arg("--yaml").arg(node_e2e_yaml.to_str().unwrap());

cmd.assert()
.success()
.stdout(predicate::str::contains("Skipping ecosystem: nodejs"))
.stdout(predicate::str::contains(
"All applicable nags have been disabled",
));

Ok(())
}

#[test]
fn test_nodejs_ecosystem_ignore_tools() -> Result<(), Box<dyn Error>> {
let node_e2e_yaml = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("test_files")
.join("node_e2e.yaml");

let mut cmd = Command::cargo_bin("stop-nagging")?;
cmd.arg("--yaml")
.arg(node_e2e_yaml.to_str().unwrap())
.arg("--ignore-tools")
.arg("yarn,pnpm");

cmd.assert()
.success()
.stdout(predicate::str::contains("Skipping ecosystem: nodejs"))
.stdout(predicate::str::contains(
"All applicable nags have been disabled",
));

Ok(())
}
32 changes: 32 additions & 0 deletions tests/test_files/node_e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ecosystems:
nodejs:
tools:
- name: "npm"
executable: "npm"
env:
NPM_CONFIG_UPDATE_NOTIFIER: "false"
commands:
- "echo 'npm e2e command executed'"
skip: false

- name: "pnpm"
executable: "pnpm"
env: {}
commands:
- "echo 'pnpm e2e command executed'"
skip: false

- name: "yarn"
executable: "yarn"
env:
YARN_IGNORE_PATH: "1"
commands:
- "echo 'yarn e2e command executed'"
skip: false

- name: "node"
executable: "node"
env: {}
commands:
- "echo 'node e2e command executed'"
skip: false

0 comments on commit 2106e3b

Please sign in to comment.