summaryrefslogtreecommitdiff
path: root/test/helpers.js
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2021-04-21 11:14:44 -0500
committerGravatar GitHub <noreply@github.com> 2021-04-21 11:14:44 -0500
commit54409a0702e4fe41e44420db9c603124207ecb20 (patch)
tree2ad25e9e23887ab46edab48e832dfd3ae104f041 /test/helpers.js
parent76932822b8fff54e56812b7fc90450904ad276ae (diff)
downloadastro-54409a0702e4fe41e44420db9c603124207ecb20.tar.gz
astro-54409a0702e4fe41e44420db9c603124207ecb20.tar.zst
astro-54409a0702e4fe41e44420db9c603124207ecb20.zip
Prettier support for `.astro` files (#106)
* docs: fix readme * chore: scaffold prettier plugin * chore(prettier): switch to cjs * test(prettier): scaffold prettier tests * test(prettier): add simple prettier tests * feat(prettier): first pass * refactor: expose parser as CJS export * test(prettier): add long expression * refactor(prettier): use Astro parser + built-in prettier doc for prettier plugin * chore: remove parser from git * chore: add prettier-plugin-astro `build` to workflow * chore: update package-lock * chore: do not build prettier-plugin-astro * fix: update engines * chore: remove NPM restriction * chore: fix workflow paths * chore: update build script * test: fix prettier expr test * chore: fix parser build on windows * refactor: add parser tsconfig, extending base config * chore: relax ban-ts-comment * chore: fix lint issue Co-authored-by: Nate Moore <nate@skypack.dev>
Diffstat (limited to 'test/helpers.js')
-rw-r--r--test/helpers.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/helpers.js b/test/helpers.js
index 6d6904004..8ca42ea11 100644
--- a/test/helpers.js
+++ b/test/helpers.js
@@ -1,7 +1,8 @@
import { fileURLToPath } from 'url';
import { build as astroBuild } from '../lib/build.js';
-import { loadConfig } from '../lib/config.js';
+import { readFile } from 'fs/promises';
import { createRuntime } from '../lib/runtime.js';
+import { loadConfig } from '../lib/config.js';
import * as assert from 'uvu/assert';
/** setup fixtures for tests */
export function setup(Suite, fixturePath) {
@@ -23,6 +24,10 @@ export function setup(Suite, fixturePath) {
}
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 () => {