Inspired by #833. We should create a robust solution to ensure each test runs with fresh state, and we successfully cleanup after each test.
Right now, some tests can cd() to change the working directory, and we won't properly cleanup after them. As an example, here's a bad afterEach() which assumes the test doesn't change working directory:
|
test.afterEach.always(t => { |
|
shell.rm('-rf', t.context.tmp); |
|
}); |
Another issue is that t.context.tmp usually refers to a relative path returned by utils.getTempDir(). I think we can be more robust by returning an absolute path.
We should create utility functions to do robust setup and teardown, to be used by every test suite (and the test suites can extend this to provide additional setup).
@freitagbr any additional thoughts?
Inspired by #833. We should create a robust solution to ensure each test runs with fresh state, and we successfully cleanup after each test.
Right now, some tests can
cd()to change the working directory, and we won't properly cleanup after them. As an example, here's a badafterEach()which assumes the test doesn't change working directory:shelljs/test/ln.js
Lines 18 to 20 in 9035b27
Another issue is that
t.context.tmpusually refers to a relative path returned byutils.getTempDir(). I think we can be more robust by returning an absolute path.We should create utility functions to do robust setup and teardown, to be used by every test suite (and the test suites can extend this to provide additional setup).
@freitagbr any additional thoughts?