Skip to content

Commit

Permalink
Failed attempt to get web e2e tests running
Browse files Browse the repository at this point in the history
  • Loading branch information
pderaaij committed Oct 11, 2023
1 parent 5832756 commit 5c3b2e6
Show file tree
Hide file tree
Showing 11 changed files with 2,336 additions and 1,943 deletions.
25 changes: 10 additions & 15 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"--extensionDevelopmentPath=${workspaceFolder}/packages/foam-vscode",
"--extensionTestsPath=${workspaceFolder}/packages/foam-vscode/out/test/suite"
],
"outFiles": [
"${workspaceFolder}/packages/foam-vscode/out/**/*.js"
],
"outFiles": ["${workspaceFolder}/packages/foam-vscode/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
Expand All @@ -29,22 +27,23 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/packages/foam-vscode"
],
"outFiles": [
"${workspaceFolder}/packages/foam-vscode/out/**/*.js"
],
"outFiles": ["${workspaceFolder}/packages/foam-vscode/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Run Foam Web extension",
"type": "pwa-extensionHost",
"type": "extensionHost",
"debugWebWorkerHost": true,
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/packages/foam-vscode",
"--extensionDevelopmentKind=web"
"--extensionDevelopmentKind=web",
"--extensionTestsPath=${workspaceFolder}/packages/foam-vscode/out/web/test/suite-web.js",
"${workspaceFolder}/packages/foam-vscode/.test-workspace"
],
"outFiles": ["${workspaceFolder}/packages/foam-vscode/dist/web/**/*.js"],
"preLaunchTask": "npm: watch-web"
"outFiles": ["${workspaceFolder}/packages/foam-vscode/out/web/**/*.js"],
"preLaunchTask": "npm: watch-web",
"sourceMaps": true
},
{
"type": "node",
Expand All @@ -55,11 +54,7 @@
"disableOptimisticBPs": true,
"cwd": "${workspaceFolder}/packages/foam-vscode",
"runtimeExecutable": "yarn",
"args": [
"jest",
"--runInBand",
"--watchAll=false"
]
"args": ["jest", "--runInBand", "--watchAll=false"]
}
]
}
23 changes: 15 additions & 8 deletions packages/foam-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"workspaceContains:.vscode/foam.json"
],
"main": "./out/extension.js",
"browser": "./dist/web/extension.js",
"browser": "./out/web/extension.js",
"capabilities": {
"untrustedWorkspaces": {
"supported": "limited",
Expand Down Expand Up @@ -657,6 +657,8 @@
"test:unit": "node ./out/test/run-tests.js --unit",
"pretest:e2e": "yarn build",
"test:e2e": "node ./out/test/run-tests.js --e2e",
"pretest:e2e-web": "npm run compile-web && tsc -p tsconfig.webTest.json",
"test:e2e-web": "node ./out/web/test/run-tests-web.js --e2e",
"lint": "dts lint src",
"clean": "rimraf out",
"watch": "tsc --build ./tsconfig.json --watch",
Expand All @@ -668,25 +670,27 @@
"publish-extension-openvsx": "npx ovsx publish foam-vscode-$npm_package_version.vsix -p $OPENVSX_TOKEN",
"publish-extension-vscode": "npx vsce publish --packagePath foam-vscode-$npm_package_version.vsix",
"publish-extension": "yarn publish-extension-vscode && yarn publish-extension-openvsx",
"compile-web": "webpack --config web/webpack.config.js",
"watch-web": "webpack --config web/webpack.config.js --watch",
"package-web": "webpack --config web/webpack.config.js --mode production --devtool hidden-source-map",
"open-in-browser": "vscode-test-web --browser=chromium --extensionDevelopmentPath=."
"compile-web": "webpack --config web/webpack.config.cjs",
"watch-web": "webpack --config web/webpack.config.cjs --watch",
"package-web": "webpack --config web/webpack.config.cjs --mode production --devtool hidden-source-map",
"open-in-browser": "vscode-test-web --verbose --browser=chromium --extensionDevelopmentPath=. .test-workspace"
},
"devDependencies": {
"@types/dateformat": "^3.0.1",
"@types/jest": "^29.5.3",
"@types/jest": "^29.5.5",
"@types/lodash": "^4.14.157",
"@types/markdown-it": "^12.0.1",
"@types/micromatch": "^4.0.1",
"@types/node": "^13.11.0",
"@types/mocha": "^10.0.2",
"@types/node": "^13.13.52",
"@types/picomatch": "^2.2.1",
"@types/remove-markdown": "^0.1.1",
"@types/vscode": "^1.70.0",
"@types/webpack-env": "1.16.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@vscode/test-web": "^0.0.45",
"assert": "^2.1.0",
"crypto-browserify": "^3.12.0",
"dts-cli": "^1.6.3",
"esbuild": "^0.17.7",
Expand All @@ -699,14 +703,17 @@
"jest-extended": "^3.2.3",
"markdown-it": "^12.0.4",
"micromatch": "^4.0.2",
"mocha": "^10.2.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"stream-browserify": "^3.0.0",
"ts-jest": "^29.1.1",
"ts-loader": "9.4.4",
"tslib": "^2.0.0",
"tty-browserify": "^0.0.1",
"typescript": "^4.9.5",
"util": "^0.12.5",
"vscode-test": "^1.3.0",
"wait-for-expect": "^3.0.2",
"webpack": "5.88.2",
Expand Down
7 changes: 6 additions & 1 deletion packages/foam-vscode/src/features/preview/wikilink-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ function contentExtractor(
parser: ResourceParser,
workspace: FoamWorkspace
): string {
let noteText = vsWorkspace.fs.readFile(toVsCodeUri(note.uri)).toString();
let noteText;

vsWorkspace.fs
.readFile(toVsCodeUri(note.uri))
.then(f => (noteText = f.toString()));

let section = Resource.findSection(note, note.uri.fragment);
if (!note.uri.fragment) {
// if there's no fragment(section), the wikilink is linking to the entire note,
Expand Down
Loading

0 comments on commit 5c3b2e6

Please sign in to comment.