-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the tests into individual files for parallelization (#54)
# Pull Request ## 📖 Description <!--- Provide some background and a description of your work. --> This work moves the individual playwright tests to their own files and leverages the setup from #53 so that temp files have their own uuid. Edit: This may seem like a lot of duplication, but I believe it is preferable to attempting to optimize too soon as we don't yet know what extra component-specific tests will be required. ### 🎫 Issues <!--- List and link relevant issues here using the keyword "closes" if this PR will close an issue, eg. closes #411 --> Continues work on #31 ## 👩💻 Reviewer Notes <!--- Provide some notes for reviewers to help them provide targeted feedback and testing. --> No changes, only file moves. ## ✅ Checklist ### General <!--- Review the list and put an x in the boxes that apply. --> - [ ] I have added tests for my changes. - [x] I have tested my changes. - [ ] I have updated the project documentation to reflect my changes. ## ⏭ Next Steps <!--- If there is relevant follow-up work to this PR, please list any existing issues or provide brief descriptions of what you would like to do next. --> - Continue work on #31
- Loading branch information
Showing
9 changed files
with
420 additions
and
303 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-cli-85b615ee-c5c0-4a54-b530-b1dfa1f03700.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "Move the tests into individual files for parallelization", | ||
"packageName": "@microsoft/fast-cli", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/fast-cli/src/components/badge/template.pw.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { execSync } from "child_process"; | ||
import path from "path"; | ||
import fs from "fs-extra"; | ||
import { | ||
expectedGeneratedComponentTemplateFiles, | ||
setup, | ||
teardown, | ||
getTempDir, | ||
getTempComponentDir, | ||
} from "../../test/helpers.js"; | ||
|
||
const uuid: string = "badge"; | ||
const tempDir: string = getTempDir(uuid); | ||
const tempComponentDir: string = getTempComponentDir(uuid); | ||
|
||
test.describe(`CLI add-foundation-component ${uuid}`, () => { | ||
test.beforeAll(() => { | ||
setup(tempDir, tempComponentDir); | ||
execSync(`cd ${tempDir} && npm run fast:init`); | ||
setup(tempDir, tempComponentDir); | ||
execSync(`cd ${tempDir} && npm run fast:add-foundation-component:${uuid}`); | ||
}); | ||
test.afterAll(() => { | ||
teardown(tempDir, tempComponentDir); | ||
}); | ||
test("should copy files from the template", () => { | ||
let files: Array<string> = []; | ||
|
||
function testGeneratedFiles(folderName: string) { | ||
const tempDirContents = fs.readdirSync(path.resolve(tempDir, "src/components/test-component", folderName)); | ||
const tempDirContentsWithFileTypes = fs.readdirSync(path.resolve(tempDir, "src/components/test-component", folderName), { | ||
withFileTypes: true | ||
}); | ||
|
||
for (let i = 0, contentLength = tempDirContents.length; i < contentLength; i++) { | ||
if (tempDirContentsWithFileTypes[i].isDirectory()) { | ||
testGeneratedFiles(tempDirContents[i]); | ||
} else { | ||
files.push( | ||
folderName | ||
? `${folderName}/${tempDirContents[i]}` | ||
: tempDirContents[i] | ||
); | ||
} | ||
} | ||
} | ||
|
||
testGeneratedFiles(""); | ||
expect(files).toEqual(expectedGeneratedComponentTemplateFiles); | ||
}); | ||
test("should be able to run the build", () => { | ||
expect( | ||
() => { | ||
execSync(`cd ${tempDir} && npm run build`); | ||
} | ||
).not.toThrow(); | ||
}); | ||
}); |
Oops, something went wrong.