Closed SamVerschueren closed 8 years ago
How about:
import test from 'ava';
import alfyTest from 'alfy-test';
test(t => {
const result = await alfyTest('workflow input', {
// options and environment variables goes here
});
console.log(result);
//=> [{title: 'foo'}]
console.log(alfyTest.cache)
//=> [CacheConf]
});
That would be the simplest the solution. The downside however is that it wouldn't allow you to run your tests concurrently.
At the moment, every time alfyTest()
is called, a new cache
and data
directory is created with tempfile
.
To keep being able to run tests concurrently, I thought about the preconfiguration
solution as described above.
Not sure If I explained the issue well enough. If not, feel free to say so and I'll try to rephrase :p.
At the moment, every time alfyTest() is called, a new cache and data directory is created with tempfile.
Isn't this what makes it possible to run the tests concurrently? A new temp dir is used for each test.
Yes, that's my point :). But with your example, where does alfyTest.cache
points to when two tests run at the same time. They will probably point to the same cache
which is not correct.
cache
at ~/tmp/foo
cache
at ~/tmp/bar
cache
in test 1
, it will point to ~/tmp/bar
which is incorrectAh, I see my mistake now. Let's go with the instance then.
Currently, using
alfy-test
is pretty straightforward and easy to use. But it has some shortcomings. It would be nice if you could get access to thealfy
cache and config.As I see it, we have two options to implement this.
Return an object
Rollback the fact that we return the
items
directly instead of the result object and attach more values to it likecache
,config
.Add preconfiguration
Sorry about the title :), let's just provide an example.
Downside is that this is a little bit more work but might be more flexible.
// @sindresorhus