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:
parent
daf3eee575
commit
4682f8fdce
4 changed files with 62 additions and 0 deletions
29
packages/astro/test/debug-component.test.js
Normal file
29
packages/astro/test/debug-component.test.js
Normal 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);
|
||||
});
|
||||
});
|
7
packages/astro/test/fixtures/debug-component/src/data/posts/my-first-post.md
vendored
Normal file
7
packages/astro/test/fixtures/debug-component/src/data/posts/my-first-post.md
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
slug: first
|
||||
---
|
||||
|
||||
Whoot!
|
||||
|
||||
# some heading
|
0
packages/astro/test/fixtures/debug-component/src/pages/index.astro
vendored
Normal file
0
packages/astro/test/fixtures/debug-component/src/pages/index.astro
vendored
Normal file
26
packages/astro/test/fixtures/debug-component/src/pages/posts/[slug].astro
vendored
Normal file
26
packages/astro/test/fixtures/debug-component/src/pages/posts/[slug].astro
vendored
Normal 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} />
|
Loading…
Reference in a new issue