-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some simple test scaffolding (#7066)
# Pull Request ## π Description This adds a simple binding, per #7037 to facilitate playwright testing. ## π©βπ» Reviewer Notes This is some simple scaffolding, no code we intend to ship is in here but this will make future PRs cleaner as they won't include unrelated changes. ## β Checklist ### General <!--- Review the list and put an x in the boxes that apply. --> - [ ] I have included a change request file using `$ npm run change` - [ ] I have added tests for my changes. - [x] I have tested my changes. - [x] I have updated the project documentation to reflect my changes. - [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/main/CONTRIBUTING.md) documentation and followed the [standards](https://github.com/microsoft/fast/blob/main/CODE_OF_CONDUCT.md#our-standards) for this project.
- Loading branch information
Showing
10 changed files
with
145 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 @@ | ||
## API Report File for "@microsoft/fast-btr" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
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
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,2 @@ | ||
# Server | ||
This project contains the web server that playwright tests are run against. To build, run `npm run build-server`. |
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,37 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { Readable } from "stream"; | ||
|
||
import express, { Request, Response } from "express"; | ||
|
||
const __dirname = path.resolve(path.dirname("")); | ||
const PORT = 8080; | ||
|
||
function handlePathRequest( | ||
mapPath: string, | ||
contentType: string, | ||
req: Request, | ||
res: Response | ||
) { | ||
res.set("Content-Type", contentType); | ||
fs.readFile(path.resolve(__dirname, mapPath), { encoding: "utf8" }, (err, data) => { | ||
const stream = (Readable as any).from(data); | ||
|
||
stream.on("readable", function (this: any) { | ||
while ((data = this.read())) { | ||
res.write(data); | ||
} | ||
}); | ||
stream.on("close", () => res.end()); | ||
stream.on("error", (e: Error) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
}); | ||
} | ||
|
||
const app = express(); | ||
app.get("/binding", (req: Request, res: Response) => | ||
handlePathRequest("./src/fixtures/binding.fixture.html", "text/html", req, res) | ||
); | ||
app.listen(PORT); |
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,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"rootDir": ".", | ||
"outDir": "dist" | ||
}, | ||
"references": [{ "path": "../src"}] | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/web-components/fast-btr/src/fixtures/binding.fixture.html
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,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
</head> | ||
<body> | ||
<custom-element text="Hello world"> | ||
<template shadowrootmode="open"> | ||
Hello world | ||
</template> | ||
</custom-element> | ||
<f-template name="custom-element"> | ||
<template> | ||
{{text}} | ||
</template> | ||
</f-template> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
packages/web-components/fast-btr/src/fixtures/binding.fixture.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,3 @@ | ||
{ | ||
"text": "Hello world" | ||
} |
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,6 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test("placeholder", async () => { | ||
// TODO: update this with tests against fixtures | ||
expect(1+1).toEqual(2); | ||
}); |
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,13 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"rootDir": ".", | ||
"outDir": "../dist/esm", | ||
"declarationDir": "../dist/dts", | ||
"lib": [ | ||
"dom", | ||
"esnext" | ||
], | ||
}, | ||
} |