refactor: remove jest and lint vitest (#62330)

This commit is contained in:
Oliver Eyton-Williams
2025-09-24 09:27:03 +02:00
committed by GitHub
parent d96d528e8c
commit 51eba06a7d
25 changed files with 253 additions and 1813 deletions
@@ -4,10 +4,7 @@ import { join } from 'path';
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { getFileName } from './get-file-name';
const basePath = join(
process.cwd(),
'__fixtures__' + process.env.JEST_WORKER_ID
);
const basePath = join(process.cwd(), '__fixtures__');
const commonPath = join(basePath, 'curriculum', 'challenges');
const block = 'project-get-file-name';
@@ -1,118 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`challenge parser > it should not parse directives we do not use 1`] = `
{
"assignments": [],
"description": "<section id="description">
<p>:root appears, :import appears</p>
<p>the next paragraph should appear</p>
::import
<p>even though it's an import directive, but if we use the full syntax <code>::directive-name{attr="name" attr2="a/path"}</code></p>
<p>it goes.</p>
<p>::: name [inline-content] {key=val}
a container directive
:::</p>
</section>",
"solutions": [],
"tests": [],
}
`;
exports[`challenge parser > it should parse md with a scene 1`] = `
{
"assignments": [],
"description": "<section id="description">
<p>This challenge has a scene.</p>
</section>",
"scene": {
"commands": [
{
"character": "Maria",
"opacity": 1,
"startTime": 0,
},
{
"character": "Maria",
"dialogue": {
"align": "center",
"text": "I'm Maria, the team lead.",
},
"finishTime": 2.4,
"startTime": 0.7,
},
{
"character": "Maria",
"opacity": 0,
"startTime": 3.4,
},
],
"setup": {
"audio": {
"filename": "1.1-1.mp3",
"finishTimestamp": 4,
"startTime": 1,
"startTimestamp": 2.6,
},
"background": "company2-center.png",
"characters": [
{
"character": "Maria",
"opacity": 0,
"position": {
"x": 50,
"y": 0,
"z": 1.5,
},
},
],
},
},
"solutions": [],
"tests": [],
}
`;
exports[`challenge parser > it should parse video questions 1`] = `
{
"assignments": [],
"description": "<section id="description">
<p>Paragraph 1</p>
<pre><code class="language-html">code example
</code></pre>
</section>",
"instructions": "<section id="instructions">
<p>Paragraph 0</p>
<pre><code class="language-html">code example 0
</code></pre>
</section>",
"questions": [
{
"answers": [
{
"answer": "<p>Some inline <code>code</code></p>",
"feedback": "<p>That is not correct.</p>",
},
{
"answer": "<p>Some <em>italics</em></p>
<p>A second answer paragraph.</p>",
"feedback": null,
},
{
"answer": "<p><code> code in </code> code tags</p>",
"feedback": null,
},
],
"solution": 3,
"text": "<p>Question line 1</p>
<pre><code class="language-js"> var x = 'y';
</code></pre>",
},
],
"solutions": [],
"tests": [],
}
`;
exports[`challenge parser > should import md from other files 1`] = `
{
"assignments": [],
@@ -243,6 +130,24 @@ exports[`challenge parser > should not mix other YAML with the frontmatter 1`] =
}
`;
exports[`challenge parser > should not parse directives we do not use 1`] = `
{
"assignments": [],
"description": "<section id="description">
<p>:root appears, :import appears</p>
<p>the next paragraph should appear</p>
::import
<p>even though it's an import directive, but if we use the full syntax <code>::directive-name{attr="name" attr2="a/path"}</code></p>
<p>it goes.</p>
<p>::: name [inline-content] {key=val}
a container directive
:::</p>
</section>",
"solutions": [],
"tests": [],
}
`;
exports[`challenge parser > should parse a more realistic md file 1`] = `
{
"assignments": [],
@@ -710,3 +615,98 @@ if(let x of xs) {
],
}
`;
exports[`challenge parser > should parse md with a scene 1`] = `
{
"assignments": [],
"description": "<section id="description">
<p>This challenge has a scene.</p>
</section>",
"scene": {
"commands": [
{
"character": "Maria",
"opacity": 1,
"startTime": 0,
},
{
"character": "Maria",
"dialogue": {
"align": "center",
"text": "I'm Maria, the team lead.",
},
"finishTime": 2.4,
"startTime": 0.7,
},
{
"character": "Maria",
"opacity": 0,
"startTime": 3.4,
},
],
"setup": {
"audio": {
"filename": "1.1-1.mp3",
"finishTimestamp": 4,
"startTime": 1,
"startTimestamp": 2.6,
},
"background": "company2-center.png",
"characters": [
{
"character": "Maria",
"opacity": 0,
"position": {
"x": 50,
"y": 0,
"z": 1.5,
},
},
],
},
},
"solutions": [],
"tests": [],
}
`;
exports[`challenge parser > should parse video questions 1`] = `
{
"assignments": [],
"description": "<section id="description">
<p>Paragraph 1</p>
<pre><code class="language-html">code example
</code></pre>
</section>",
"instructions": "<section id="instructions">
<p>Paragraph 0</p>
<pre><code class="language-html">code example 0
</code></pre>
</section>",
"questions": [
{
"answers": [
{
"answer": "<p>Some inline <code>code</code></p>",
"feedback": "<p>That is not correct.</p>",
},
{
"answer": "<p>Some <em>italics</em></p>
<p>A second answer paragraph.</p>",
"feedback": null,
},
{
"answer": "<p><code> code in </code> code tags</p>",
"feedback": null,
},
],
"solution": 3,
"text": "<p>Question line 1</p>
<pre><code class="language-js"> var x = 'y';
</code></pre>",
},
],
"solutions": [],
"tests": [],
}
`;
@@ -45,21 +45,21 @@ describe('challenge parser', () => {
expect(parsed).toMatchSnapshot();
});
it('it should parse video questions', async () => {
it('should parse video questions', async () => {
const parsed = await parseMD(
resolve(__dirname, '__fixtures__/with-video-question.md')
);
expect(parsed).toMatchSnapshot();
});
it('it should not parse directives we do not use', async () => {
it('should not parse directives we do not use', async () => {
const parsed = await parseMD(
resolve(__dirname, '__fixtures__/with-directives.md')
);
expect(parsed).toMatchSnapshot();
});
it('it should parse md with a scene', async () => {
it('should parse md with a scene', async () => {
const parsed = await parseMD(resolve(__dirname, '__fixtures__/scene.md'));
expect(parsed).toMatchSnapshot();
});
@@ -272,29 +272,6 @@ const Button = () => {
};`);
});
/* Revisit this once we've decided what to do about multifile imports. I
think the best approach is likely to be use the following format for .files
it('combines all the code of a specific language into a single file', () => {
{ css: [css files],
html: [html files],
...
}
or
{ css: {css files},
html: {html files},
...
}
depending on what's easier to work with in graphQL
});
*/
it('should throw an error if a seed has no contents', () => {
expect.assertions(1);
expect(() => plugin(withEmptyContentsAST, file)).toThrow(
@@ -64,9 +64,11 @@ describe('replace-imports', () => {
it('should proceed when the imported file exists', async () => {
const plugin = addImports();
await new Promise(resolve => {
plugin(importsAST, correctFile, resolve);
});
await expect(
new Promise(resolve => {
plugin(importsAST, correctFile, resolve);
})
).resolves.toBeUndefined();
});
it('should fail when the imported file cannot be found', async () => {
@@ -44,9 +44,9 @@ describe('external curriculum data build', () => {
});
test('there should be an endpoint to request submit types from', () => {
fs.existsSync(
`${clientStaticPath}/curriculum-data/${VERSION}/submit-types.json`
);
expect(
fs.existsSync(`${clientStaticPath}/curriculum-data/submit-types.json`)
).toBeTruthy();
});
test('the available-superblocks file should have the correct structure', async () => {
@@ -60,12 +60,8 @@ describe('external curriculum data build', () => {
const result = validateAvailableSuperBlocks(availableSuperblocks);
if (result.error) {
throw Error(
`file: available-superblocks.json
${result.error.message}`
);
}
expect(result.error?.details).toBeUndefined();
expect(result.error).toBeFalsy();
});
test('the super block files generated should have the correct schema', async () => {
@@ -93,10 +89,8 @@ ${result.error.message}`
const result = validateSuperBlock(JSON.parse(fileContent));
if (result.error) {
throw Error(`file: ${fileInArray}
${result.error.message}`);
}
expect(result.error?.details).toBeUndefined();
expect(result.error).toBeFalsy();
});
});
@@ -82,12 +82,8 @@ describe('external curriculum data build', () => {
expect.arrayContaining(filteredSuperBlockStages)
);
if (result.error) {
throw Error(
`file: available-superblocks.json
${result.error.message}`
);
}
expect(result.error?.details).toBeUndefined();
expect(result.error).toBeFalsy();
});
test('the super block files generated should have the correct schema', async () => {
@@ -118,10 +114,8 @@ ${result.error.message}`
const result = validateSuperBlock(JSON.parse(fileContent));
if (result.error) {
throw Error(`file: ${fileInArray}
${result.error.message}`);
}
expect(result.error?.details).toBeUndefined();
expect(result.error).toBeFalsy();
});
});