Skip to content

Commit

Permalink
Add scaffolding for a simple binding for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janechu committed Jan 24, 2025
1 parent 93f3962 commit affdab9
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 43 deletions.
9 changes: 6 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/web-components/fast-btr/docs/api-report.api.md
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)

```
80 changes: 40 additions & 40 deletions packages/web-components/fast-btr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@
"private": true,
"type": "module",
"author": {
"name": "Microsoft",
"url": "https://discord.gg/FcSNfg4"
"name": "Microsoft",
"url": "https://discord.gg/FcSNfg4"
},
"homepage": "https://www.fast.design/",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/Microsoft/fast.git",
"directory": "packages/web-components/fast-btr"
"type": "git",
"url": "git+https://github.com/Microsoft/fast.git",
"directory": "packages/web-components/fast-btr"
},
"bugs": {
"url": "https://github.com/Microsoft/fast/issues/new/choose"
"url": "https://github.com/Microsoft/fast/issues/new/choose"
},
"scripts": {
"clean": "tsc -b --clean src",
"build": "tsc -b src && npm run doc",
"doc": "api-extractor run --local",
"doc:ci": "api-extractor run",
"prepublishOnly": "npm run clean && npm run build",
"build-server": "tsc -b server",
"eslint": "eslint . --ext .ts",
"eslint:fix": "eslint . --ext .ts --fix",
"pretest": "npm run build-server && npm run build",
"prettier:diff": "prettier --config ../../../.prettierrc \"**/*.{ts,html}\" --list-different",
"prettier": "prettier --config ../../../.prettierrc --write \"**/*.{ts,html}\"",
"test": "playwright test --config=playwright.config.cjs",
"test-server": "node server/dist/server.js",
"install-playwright-browsers": "npm run playwright install"
"clean": "tsc -b --clean src",
"build": "tsc -b src && npm run doc",
"doc": "api-extractor run --local",
"doc:ci": "api-extractor run",
"prepublishOnly": "npm run clean && npm run build",
"build-server": "tsc -b server",
"eslint": "eslint . --ext .ts",
"eslint:fix": "eslint . --ext .ts --fix",
"pretest": "npm run build-server && npm run build",
"prettier:diff": "prettier --config ../../../.prettierrc \"**/*.{ts,html}\" --list-different",
"prettier": "prettier --config ../../../.prettierrc --write \"**/*.{ts,html}\"",
"test": "playwright test --config=playwright.config.cjs",
"test-server": "node server/dist/server.js",
"install-playwright-browsers": "npm run playwright install"
},
"description": "A package for facilitating rendering FAST Web Components in a non-browser environment.",
"exports": {
".": {
"types": "./dist/dts/index.d.ts",
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
".": {
"types": "./dist/dts/index.d.ts",
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
},
"peerDependencies": {
"@microsoft/fast-element": "^2.0.1"
"@microsoft/fast-element": "^2.0.1"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.47.0",
"@microsoft/fast-element": "^2.0.1",
"@playwright/test": "^1.49.0",
"@types/express": "^4.17.21",
"@types/node": "^17.0.17",
"express": "^4.19.2",
"typescript": "~5.3.0"
"@microsoft/api-extractor": "^7.47.0",
"@microsoft/fast-element": "^2.0.1",
"@playwright/test": "^1.49.0",
"@types/express": "^4.17.21",
"@types/node": "^17.0.17",
"express": "^4.19.2",
"typescript": "~5.3.0"
},
"beachball": {
"disallowedChangeTypes": [
"major",
"minor",
"patch"
],
"tag": "alpha"
"disallowedChangeTypes": [
"major",
"minor",
"patch"
],
"tag": "alpha"
}
}
}
2 changes: 2 additions & 0 deletions packages/web-components/fast-btr/server/README.md
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`.
37 changes: 37 additions & 0 deletions packages/web-components/fast-btr/server/server.ts
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);
9 changes: 9 additions & 0 deletions packages/web-components/fast-btr/server/tsconfig.json
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 packages/web-components/fast-btr/src/fixtures/binding.fixture.html
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"text": "Hello world"
}
13 changes: 13 additions & 0 deletions packages/web-components/fast-btr/src/tsconfig.json
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"
],
},
}

0 comments on commit affdab9

Please sign in to comment.