Add Debug tests (#1882)

* Make Debug use the Code component

* Use a random port so parallel testing works

* some debugging

* Skip these tests for now

* Dont run these tests on osx
This commit is contained in:
Matthew Phillips 2021-11-19 10:06:31 -05:00 committed by GitHub
parent daf3eee575
commit 4682f8fdce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,29 @@
import { expect } from 'chai';
import { loadFixture } from './test-utils.js';
import os from 'os';
// TODO: fix these tests on macOS
const isMacOS = os.platform() === 'darwin';
describe('<Debug />', () => {
if (isMacOS) return;
/** @type {import('./test-utils').Fixture} */
let fixture
/** @type {import('./test-utils').DevServer} */
let devServer;
before(async () => {
fixture = await loadFixture({ projectRoot: './fixtures/debug-component/' });
devServer = await fixture.startDevServer();
});
after(async () => {
devServer && await devServer.stop();
});
it('Works in markdown pages', async () => {
const response = await fixture.fetch('/posts/first');
expect(response.status).to.equal(200);
});
});

View file

@ -0,0 +1,7 @@
---
slug: first
---
Whoot!
# some heading

View file

@ -0,0 +1,26 @@
---
import Debug from 'astro/debug';
// all the content that should be generated
export async function getStaticPaths() {
const data = Astro.fetchContent('../../data/posts/*.md')
const allArticles = data.map(({ astro, file, url, ...article }) => {
return {
params: { slug: article.slug },
props: {
article: article,
content: astro.html,
md: astro.source,
}
}
})
return allArticles
}
const x = Astro.props
---
<Debug {x} />