summaryrefslogtreecommitdiff
path: root/test/helpers.js
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2021-04-30 16:33:35 -0500
committerGravatar GitHub <noreply@github.com> 2021-04-30 16:33:35 -0500
commit4df1347156cf2632ea2f3475d3a5f8f08d197cc3 (patch)
tree9d50de89dfe62827c32a8a4046120af4ab61dc0c /test/helpers.js
parent1d498facc8f78a3ffbfecd05cc6ecd45e8a4a1ae (diff)
downloadastro-4df1347156cf2632ea2f3475d3a5f8f08d197cc3.tar.gz
astro-4df1347156cf2632ea2f3475d3a5f8f08d197cc3.tar.zst
astro-4df1347156cf2632ea2f3475d3a5f8f08d197cc3.zip
Migrate to `yarn` monorepo (#157)
* chore: use monorepo * chore: scaffold astro-scripts * chore: move tests inside packages/astro * chore: refactor tests, add scripts * chore: move parser to own module * chore: move runtime to packages/astro * fix: move parser to own package * test: fix prettier-plugin-astro tests * fix: tests * chore: update package-lock * chore: add changesets * fix: cleanup examples * fix: starter example * chore: update changeset config * chore: update changeset config * chore: setup changeset release workflow * chore: bump lockfiles * chore: prism => astro-prism * fix: tsc --emitDeclarationOnly * chore: final cleanup, switch to yarn * chore: add lerna * chore: update workflows to yarn * chore: update workflows * chore: remove lint workflow * chore: add astro-dev script * chore: add symlinked README
Diffstat (limited to 'test/helpers.js')
-rw-r--r--test/helpers.js73
1 files changed, 0 insertions, 73 deletions
diff --git a/test/helpers.js b/test/helpers.js
deleted file mode 100644
index b14005563..000000000
--- a/test/helpers.js
+++ /dev/null
@@ -1,73 +0,0 @@
-import { fileURLToPath } from 'url';
-import { build as astroBuild } from '../lib/build.js';
-import { readFile } from 'fs/promises';
-import { createRuntime } from '../lib/runtime.js';
-import { loadConfig } from '../lib/config.js';
-import * as assert from 'uvu/assert';
-import execa from 'execa';
-
-/** setup fixtures for tests */
-export function setup(Suite, fixturePath) {
- let runtime, setupError;
-
- Suite.before(async (context) => {
- const astroConfig = await loadConfig(fileURLToPath(new URL(fixturePath, import.meta.url)));
-
- const logging = {
- level: 'error',
- dest: process.stderr,
- };
-
- try {
- runtime = await createRuntime(astroConfig, { logging });
- } catch (err) {
- console.error(err);
- setupError = err;
- }
-
- context.runtime = runtime;
- context.readFile = async (path) => {
- const resolved = fileURLToPath(new URL(`${fixturePath}${path}`, import.meta.url));
- return readFile(resolved).then((r) => r.toString('utf-8'));
- };
- });
-
- Suite.after(async () => {
- (await runtime) && runtime.shutdown();
- });
-
- Suite('No errors creating a runtime', () => {
- assert.equal(setupError, undefined);
- });
-}
-
-export function setupBuild(Suite, fixturePath) {
- let build, setupError;
-
- Suite.before(async (context) => {
- const astroConfig = await loadConfig(fileURLToPath(new URL(fixturePath, import.meta.url)));
-
- const logging = {
- level: 'error',
- dest: process.stderr,
- };
-
- build = (...args) => astroBuild(astroConfig, ...args);
- context.build = build;
- });
-
- Suite.after(async () => {
- // Shutdown i guess.
- });
-
- Suite('No errors creating a runtime', () => {
- assert.equal(setupError, undefined);
- });
-}
-
-const cliURL = new URL('../astro.mjs', import.meta.url);
-export function runDevServer(root, additionalArgs = []) {
- const args = [cliURL.pathname, 'dev', '--project-root', root.pathname].concat(additionalArgs);
- const proc = execa('node', args);
- return proc;
-} \ No newline at end of file