18 Commits

Author SHA1 Message Date
Nate Fischer
1a31356343 refactor: use require instead of import
No change to logic. This swaps over tests to use require() since
everything is currently designed for the commonjs module system.
2025-04-07 22:44:24 -07:00
Nate Fischer
39ebb71846 test: add coverage for exit function
This adds test coverage for the shell.exit() function. This also
refactors how we mock stdout/stderr and adds support for mocking
process.exit() (which was needed for this change).

While I was writing these tests, I realized there was an edge case I
missed in PR #1122. This change fixes that edge case.

Issue #1013
2023-11-11 18:27:54 -08:00
Alexander Regueiro
cea0e58250 Added -q (quiet) option to push, popd, dirs functions. (#777)
* Added `-q` (quiet) option to `push`, `popd`, `dirs` functions.

* Added unit tests for pushd/popd quiet mode.

* Added tests for `pushd` and `popd` with quiet mode off.

* Updated docs for `pushd` and `popd` functions.

* Moved preliminary `pushd` commands for `popd` tests before disabling of silent flag.
2017-10-09 20:53:17 -07:00
Nate Fischer
2ee83ebf74 refactor(test): update AVA and refactor tests (#760)
This updates tests for `AVA` 19.0.0+.

`AVA` 0.18.0 has a breaking change which changes the current working directory
for tests. As a result, we need to change 'resources' -> 'test/resources' (and
 similar path changes).

`AVA` 0.19.0 has a breaking change that all tests must run at least one assert.
This breaking change was already resolved by #746, so no change was necessary in
this PR.

This updates to `AVA` 0.21.0, since there are no other breaking changes.
2017-08-11 11:03:13 -07:00
Nate Fischer
b6b2cd84ef fix: convert error output to be consistent cross-platform (#684)
* fix: convert error output to be consistent cross-platform

The error output produced by `shell.error()` or `result.stderr` should
not be inconsistent between platforms. This ensures that path separators
are always printed by ShellJS as `/` instead of as `\` on Windows. This
should allow scripts using ShellJS to be more consistent cross-platform.

We were not previously relying on error output to always be consistent--
only checking its truthiness. Since this was not part of our tested API,
it should be reasonable to change this and release in a patch.

Fixes #681

* Fix broken pushd test case

* Fix TODO in a test case
2017-03-06 00:54:26 -08:00
Nate Fischer
ac0ff873f1 refactor: add config.reset() and .resetForTesting() (#641)
Add .reset() and .resetForTesting() to shell.config and use .resetForTesting()
as a standard set-up for unit tests.
2017-01-07 22:40:38 -08:00
Brandon Freitag
7fa4b995bf Finalize moving to ava (#630)
* Move ava-test/ directory to test/

* Remove unnecessary run-tests.js script

* Run only ava during npm test script
2016-12-20 11:27:02 -08:00
Nate Fischer
63041b74d6 test: refactor pushd tests to AVA (#627) 2016-12-19 22:51:54 -08:00
Nate Fischer
2395214fee chore: switch to eslint (#504)
* chore: switch to eslint

* fix: works on older versions of NodeJS now

* chore: fix curly braces

* chore: fix indents and remove jshint references
2016-08-07 12:16:29 -07:00
Burak Yigit Kaya
175f5e1efd Fix tests on Windows 2016-01-27 22:53:31 +02:00
Nate Fischer
74f1ff8748 Commands that have multiple errors now produce cleaner log output. Errors are
echoed to stderr. exec() supports a new stderr field.
2016-01-12 17:02:19 -08:00
Artur Adib
193968a978 remove old shims 2013-09-21 10:19:38 -04:00
Marcus Stade
829bdbc785 Improved tests and implementation.
Plenty of errors surfaced with better test coverage. Aside from fixing
the broken implementations, this also prompted me to fully implement
the dirs command.

Also changed the run-tests script to always set cwd to the test folder,
so that tests that change cwd don't affect others (ehum, that'd be
mine.)

More tests to follow.
2012-12-29 03:43:23 +01:00
Marcus Stade
387babda6b Improved tests a little bit.
Added pwd check to all tests, and added a test for invalid use of
popd. More tests to come.
2012-12-27 18:06:52 +01:00
Marcus Stade
19d3d91bb6 Make _dirs() return an array instead of a string 2012-12-27 17:52:11 +01:00
Marcus Stade
18a10bb3d9 Added semicolons and removed dirs from exports 2012-12-27 17:46:37 +01:00
Marcus Stade
4bc3725137 Fixed tests. 2012-12-26 03:18:06 +01:00
Marcus Stade
3e29c02734 Initial work 2012-12-25 20:57:38 +01:00