diff options
Diffstat (limited to 'test/helpers.js')
-rw-r--r-- | test/helpers.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/helpers.js b/test/helpers.js new file mode 100644 index 000000000..c913ef912 --- /dev/null +++ b/test/helpers.js @@ -0,0 +1,33 @@ +import { createRuntime } from '../lib/runtime.js'; +import { loadConfig } from '../lib/config.js'; +import * as assert from 'uvu/assert'; + +export function setup(Suite, fixturePath) { + let runtime, setupError; + + Suite.before(async (context) => { + const astroConfig = await loadConfig(new URL(fixturePath, import.meta.url).pathname); + + const logging = { + level: 'error', + dest: process.stderr, + }; + + try { + runtime = await createRuntime(astroConfig, { logging }); + } catch (err) { + console.error(err); + setupError = err; + } + + context.runtime = runtime; + }); + + Suite.after(async () => { + (await runtime) && runtime.shutdown(); + }); + + Suite('No errors creating a runtime', () => { + assert.equal(setupError, undefined); + }); +} |