Firebase - Issue during deployment getting error : Error: An unexpected error has occurred - node.js

When i test my application using the below command in the localhost, it works fine.
firebase serve --only functions,hosting
But when i tried to deploy it using below command. It fails with error message (Error: An unexpected error has occurred.). Does not give much details
firebase deploy
or
firebase deploy --only functions,hosting
Initial error was to update firebase-functions and firebase-admin so i went ahead and updated it after reading the guide in below link. Iam not using any of those features.
https://firebase.google.com/docs/functions/beta-v1-diff#realtime-database
npm install firebase-functions#latest --save
npm install firebase-admin#5.11.0 --save
npm install -g firebase-tools
Here is the output using command : firebase deploy --debug
[debug] [2018-05-14T18:59:35.734Z] ----------------------------------------------------------------------
[debug] [2018-05-14T18:59:35.739Z] Command: C:\Program Files\nodejs\node.exe C:\Users\Sushanth\AppData\Roaming\npm\node_modules\firebase-tools\bin\firebase deploy --only functions,hosting
[debug] [2018-05-14T18:59:35.740Z] CLI Version: 3.18.4
[debug] [2018-05-14T18:59:35.740Z] Platform: win32
[debug] [2018-05-14T18:59:35.740Z] Node Version: v8.10.0
[debug] [2018-05-14T18:59:35.741Z] Time: Tue May 15 2018 00:29:35 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:35.741Z] ----------------------------------------------------------------------
[debug]
[debug] [2018-05-14T18:59:35.759Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2018-05-14T18:59:35.762Z] > authorizing via signed-in user
[debug] [2018-05-14T18:59:35.765Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2018-05-14T18:59:35.766Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
{ refresh_token: '1/V2t23LrBy9dznRfmTQnnh-0x3k3RrWFiA2EbNwRErOU',
client_id: '563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
grant_type: 'refresh_token',
scope: 'email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid' }
Tue May 15 2018 00:29:35 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:36.385Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T18:59:36.393Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/stashit-7885bob
Tue May 15 2018 00:29:36 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:37.606Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T18:59:37.607Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/stashit-7885bob/tokens
Tue May 15 2018 00:29:37 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:38.662Z] <<< HTTP RESPONSE 200
[info]
[info] === Deploying to 'stashit-7885bob'...
[info]
[info] i deploying functions, hosting
[debug] [2018-05-14T18:59:46.087Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"body-parser": "^1.18.2",
"cookie-parser": "^1.4.3",
"cors": "^2.8.4",
"ejs": "^2.5.9",
"express": "^4.16.3",
"firebase": "^5.0.2",
"firebase-admin": "^5.11.0",
"firebase-functions": "^1.0.2"
},
"private": true
}
[info] i functions: ensuring necessary APIs are enabled...
[debug] [2018-05-14T18:59:46.087Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/stashit-7885bob?view=CONSUMER_VIEW
Tue May 15 2018 00:29:46 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:46.092Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/stashit-7885bob?view=CONSUMER_VIEW
Tue May 15 2018 00:29:46 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:48.558Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T18:59:48.586Z] <<< HTTP RESPONSE 200
[info] + functions: all necessary APIs are enabled
[debug] [2018-05-14T18:59:48.588Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/stashit-7885bob
Tue May 15 2018 00:29:48 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:50.672Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T18:59:50.673Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/288692255744:getServerAppConfig
Tue May 15 2018 00:29:50 GMT+0530 (India Standard Time)
[debug] [2018-05-14T18:59:51.783Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T18:59:52.294Z] TypeError: Path must be a string. Received [ 'public/',
'public/css',
'public/js',
'public/mdb-css',
'public/mdb-js',
'functions/js',
'public/images' ]
at assertPath (path.js:28:11)
at Object.resolve (path.js:211:7)
at module.exports (C:\Users\Sushanth\AppData\Roaming\npm\node_modules\firebase-tools\lib\resolveProjectPath.js:7:15)
at module.exports (C:\Users\Sushanth\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\hosting\prepare.js:31:39)
at _chain (C:\Users\Sushanth\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\index.js:26:38)
at C:\Users\Sushanth\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\index.js:29:14
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
[error]
[error] Error: An unexpected error has occurred.
And my firebase.json file looks like this
{
"hosting": {
"public": ["public/", "public/css", "public/js", "public/mdb-css", "public/mdb-js", "functions/js", "public/images"],
"rewrites":[
{"source" : "/timestamp", "function" : "app"},
{"source" : "/stashlogin", "function" : "app"},
{"source" : "/stash", "function" : "app"},
{"source" : "/get", "function" : "app"},
{"source" : "/put", "function" : "app"},
{"source" : "/categorycolor", "function" : "app"},
{"source" : "/category", "function" : "app"},
{"source" : "/category/**", "function" : "app"},
{"source" : "/put/**", "function" : "app"},
{"source" : "/delete/**", "function" : "app"},
{"source" : "/profile", "function" : "app"},
{"source" : "/feedback", "function" : "app"}
],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
Please let me know how to proceed as there is not reason for the error message. I am actually stuck.

Your public directory must be a single string, not an array.

Related

getting Invalid semver string: "undefined"

Going through a Udemy tutorial on AWS CDK and Typescript. The video is about two years old and the instructor had just started using the new 2.0.0 release of the CDK. So, that may be part of my problem. I'm getting the below error when I run CDK synth --verbose
Invalid semver string: "undefined"
[21:30:22] Error: Invalid semver string: "undefined"
at parseVersion (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:31:8255000)
at Function.validate (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:31:8255125)
at Function.loadManifest (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:32:594)
at Function.loadAssemblyManifest (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:31:8254222)
at new CloudAssembly (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:32:14396)
at createAssembly (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:329:15973)
at execProgram (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:329:15438)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.CloudExecutable.synthesizer (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:385:50431)
at async CloudExecutable.doSynthesize (C:\Users\DREWA\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:329:7689)
Didn't know I needed a manifest.json file until I got the error beforehand that it wasn't found when I ran "cdk synth". No idea what should go in it, so I downloaded a sample from AWS. Here are the contents
{
"default": {
"version": "v0.0.1",
"telemetry": {
"deploy": true,
"env": {
"telemetryTopic": "smartproduct/telemetry"
}
},
"events": {
"deploy": true,
"env": {
"eventTopic": "smartproduct/event"
}
},
"jitr": {
"deploy": true
},
"api": {
"deploy": true
},
"ownerapp": {
"deploy": true
}
}
}
Here are the versions:
Node: v14.17.6
NPM: 6.14.15
aws-cdk: 2.63.2
Couldn't find any help in Stack Overflow, github or AWS regarding this particular error and scenario. Is there a way to run cdk synth without requiring a manifest.json?

simplest hello world AWS Lambda runing nodejs failing /var/runtime/Runtime.js:67:14

I have very little experience on this stack and I've tried several google searches. I didn't find anything!
I'm trying to build a function as simple as possible. A "hello world" style, without compiling the docker container;
This is what I have done ...
docker-compose.yml
version: '3.7'
volumes:
lambda-node:
driver: local
services:
lambda-node:
image: amazon/aws-lambda-nodejs:12
environment:
- STAGE=${STAGE:-local}
ports:
- 9000:8080
volumes:
- ./src/node:/var/task
command:
- app.handler
./src/node/app.js
exports.handler = async (event, context) => {
console.log(event);
console.log(context);
return "{\"message\": \"Hello World.\"}";
}
./src/node/package.json
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
PS: I tried:
Multiple return options, using or not using JSON.stringify and several other attempts, so I don't believe it's the return itself. To me it seams the script is not event been loaded;
Generate a package-lock.json
I started using TAG 14.2022.02.01.09 then I started using TAG 14 and finally I'm doing tests with TAG 10. They all generate the same result
I even try to run the script as a module!
The output
$ docker-compose up
Starting magma_lambda-node_1 ... done
Attaching to magma_lambda-node_1
lambda-node_1 | 22 Feb 2022 12:20:09,249 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)
lambda-node_1 | 22 Feb 2022 12:20:16,280 [INFO] (rapid) extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory
lambda-node_1 | 22 Feb 2022 12:20:16,280 [WARNING] (rapid) Cannot list external agents error=open /opt/extensions: no such file or directory
lambda-node_1 | START RequestId: e9449065-e27d-444a-b5f0-200ed50bb9b8 Version: $LATEST
lambda-node_1 | 2022-02-22T12:20:16.432Z e9449065-e27d-444a-b5f0-200ed50bb9b8 ERROR Invoke Error {"errorType":"SyntaxError","errorMessage":"Unexpected end of JSON input","stack":["SyntaxError: Unexpected end of JSON input"," at JSON.parse (<anonymous>)"," at Runtime.handleOnce (/var/runtime/Runtime.js:67:14)"]}
lambda-node_1 | END RequestId: e9449065-e27d-444a-b5f0-200ed50bb9b8
lambda-node_1 | REPORT RequestId: e9449065-e27d-444a-b5f0-200ed50bb9b8 Init Duration: 0.35 ms Duration: 160.00 ms Billed Duration: 161 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
Sorry advance for the words! But dud, am I disappointed ...
Can anybody tell me what on earth am I doing wrong?
Thanks

Can't deploy Angular Universal to Firebase Functions

Whenever I try to deploy my Angular Universal app, the hosting gets deployed without issue, but I'm faced with the following error whenever I run ng deploy:
Functions did not deploy properly.
Everything functions without error when I run npm run build:ssr though, so I'm not sure what is causing this error. Here is my firebase.json file:
{
"hosting": [
{
"target": "iquench-website",
"public": "dist\\dist\\browser",
"ignore": [
"**/.*"
],
"headers": [
{
"source": "*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].+(css|js)",
"headers": [
{
"key": "Cache-Control",
"value": "public,max-age=31536000,immutable"
}
]
}
],
"rewrites": [
{
"source": "**",
"function": "ssr"
}
]
}
],
"functions": {
"source": "dist"
}
}
and my .firebaserc:
{
"projects": {
"default": "PROJECT_NAME"
},
"targets": {
"PROJECT_NAME": {
"hosting": {
"iquench-website": [
"PROJECT_NAME"
]
}
}
}
}
Here are the logs when deploying:
=== Deploying to 'PROJECT_NAME'...
i deploying functions, hosting
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudfunctions.googleapis.com is enabled
+ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing dist directory for uploading...
i functions: packaged dist (5.72 MB) for uploading
+ functions: dist folder uploaded successfully
i hosting[PROJECT_NAME]: beginning deploy...
i hosting[PROJECT_NAME]: found 115 files in dist\dist\browser
+ hosting[PROJECT_NAME]: file upload complete
i functions: current functions in project: backupFirestore(us-central1), deleteUser(us-central1), ssr(us-central1)
i functions: uploading functions in project: ssr(us-central1)
i functions: updating Node.js 10 function ssr(us-central1)...
+ scheduler: required API cloudscheduler.googleapis.com is enabled
! functions[ssr(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
ssr
To try redeploying those functions, run:
firebase deploy --only "functions:ssr"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Functions did not deploy properly.

Karma test runner does not run mocha tests

When running tests using mocha (./node_modules/.bin/mocha test) the tests in the test file run, and the following is outputted to powershell:
TEST ************
myFunc
- a pending test
0 passing (4ms)
1 pending
When running the same file using karma (./node_modules/.bin/karma start), the console.log("TEST ************"); prints out, but the test suite does not run. Karma gives the following output:
10 05 2020 14:27:24.326:WARN [karma]: No captured browser, open http://localhost:9876/
10 05 2020 14:27:24.352:INFO [karma-server]: Karma v5.0.5 server started at http://0.0.0.0:9876/
10 05 2020 14:27:24.352:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
10 05 2020 14:27:24.358:INFO [launcher]: Starting browser ChromeHeadless
10 05 2020 14:27:26.898:INFO [Chrome Headless 81.0.4044.138 (Windows 10)]: Connected on socket IBnhFoW1f9d9zLHsAAAA with id 8234878
Chrome Headless 81.0.4044.138 (Windows 10) LOG: 'TEST ************'
Chrome Headless 81.0.4044.138 (Windows 10): Executed 0 of 1 (skipped 1) SUCCESS (0.004 secs / 0 secs)
TOTAL: 0 SUCCESS
test.js
console.log("TEST ************");
describe('myFunc', function() {
it("a pending test");
});
karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ["mocha"],
files: [ "test/test.js"],
plugins: [
"karma-chrome-launcher",
"karma-mocha"
],
browsers: ["ChromeHeadless"]
})
}
package.json
{
"name": "karma-mocha-test",
"devDependencies": {
"karma-chrome-launcher": "^3.1.0",
"karma": "^5.0.5",
"karma-mocha": "^2.0.1",
"mocha": "^7.1.2"
}
}
What am I missing here to make karma run mocha tests and display the results in powershell?
I'm missing a reporter, like so:
,reporters: ["mocha", "coverage-istanbul"]

Importing Node core modules breaks Karma tests (using #open-wc/testing-karma)

macOS Mojave 10.14.5
Node.js v12.6.0
I am trying to set up testing for a vanilla web component, which led me to the #open-wc/testing-karma package. When doing something like this:
src/redblue-video.test.js
import { html, fixture, expect } from '#open-wc/testing';
import RedBlueVideo from './parser-omni.js'; // ES6 web component class
customElements.define( 'redblue-video', RedBlueVideo );
describe( '<redblue-video />', () => {
it( 'embeds YouTube videos', async () => {
const el = await fixture( html`<redblue-video></redblue-video>` );
expect( el ).dom.to.equal( `<redblue-video class="redblue-video" role="application"></redblue-video>` );
} );
} );
…and running it with yarn test (karma start), the test executes fine:
$ yarn test
yarn run v1.17.3
$ karma start
START:
01 08 2019 19:11:03.202:WARN [filelist]: Pattern "/Users/Hugh/Sites/redblue/__snapshots__/**/*.md" does not match any file.
01 08 2019 19:11:03.223:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
01 08 2019 19:11:03.223:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox, ChromeHeadlessNoSandbox with concurrency unlimited
01 08 2019 19:11:03.226:INFO [launcher]: Starting browser ChromeHeadless
01 08 2019 19:11:03.240:INFO [launcher]: Starting browser ChromeHeadless
01 08 2019 19:11:03.893:INFO [HeadlessChrome 75.0.3770 (Mac OS X 10.14.5)]: Connected on socket 4QcOBy0C1_X43S5zAAAA with id 15906039
01 08 2019 19:11:03.922:INFO [HeadlessChrome 75.0.3770 (Mac OS X 10.14.5)]: Connected on socket bcOgxLUp8s7CAZUqAAAB with id 41870378
HeadlessChrome 75.0.3770 (Mac OS X 10.14.5) WARN: 'No Embed URL found'
HeadlessChrome 75.0.3770 (Mac OS X 10.14.5) WARN: 'No Embed URL found'
HeadlessChrome 75.0.3770 (Mac OS X 10.14.5) WARN: 'No nonlinear playlists found'
HeadlessChrome 75.0.3770 (Mac OS X 10.14.5) WARN: 'No nonlinear playlists found'
<redblue-video />
✔ embeds YouTube videos
Finished in 0.025 secs / 0.038 secs # 19:11:07 GMT-0400 (Eastern Daylight Time)
SUMMARY:
✔ 2 tests completed
✨ Done in 5.07s.
But if I try to pull in readFileSync, as in:
import { html, fixture, expect } from '#open-wc/testing';
import { readFileSync } from 'fs';
import RedBlueVideo from './parser-omni.js'; // ES6 web component class
customElements.define( 'redblue-video', RedBlueVideo );
describe( '<redblue-video />', () => {
it( 'embeds YouTube videos', async () => {
const markup = readFileSync( './examples/youtube-embed.hvml' );
const el = await fixture( html`<redblue-video>${markup}</redblue-video>` );
expect( el ).dom.to.equal( `<redblue-video class="redblue-video" role="application">${markup}</redblue-video>` );
} );
} );
…then the test does not run:
$ yarn test
yarn run v1.17.3
$ karma start
START:
01 08 2019 19:16:08.364:WARN [filelist]: Pattern "/Users/Hugh/Sites/redblue/__snapshots__/**/*.md" does not match any file.
01 08 2019 19:16:08.384:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
01 08 2019 19:16:08.385:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox, ChromeHeadlessNoSandbox with concurrency unlimited
01 08 2019 19:16:08.390:INFO [launcher]: Starting browser ChromeHeadless
01 08 2019 19:16:08.397:INFO [launcher]: Starting browser ChromeHeadless
01 08 2019 19:16:09.100:INFO [HeadlessChrome 75.0.3770 (Mac OS X 10.14.5)]: Connected on socket a8fHrCGFmHdZC5qOAAAA with id 88214959
01 08 2019 19:16:09.799:INFO [HeadlessChrome 75.0.3770 (Mac OS X 10.14.5)]: Connected on socket Cq0xMj1wOchVYG13AAAB with id 63311008
HeadlessChrome 75.0.3770 (Mac OS X 10.14.5) ERROR: 'failed to load element http://localhost:9876/base/src/redblue-video.test.js?2133f326ffd8a86c0252453f23aee7a13f7ff7ad'
HeadlessChrome 75.0.3770 (Mac OS X 10.14.5) ERROR: 'failed to load element http://localhost:9876/base/src/redblue-video.test.js?2133f326ffd8a86c0252453f23aee7a13f7ff7ad'
Finished in 0.008 secs / 0 secs # 19:16:11 GMT-0400 (Eastern Daylight Time)
SUMMARY:
✔ 0 tests completed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Is it impossible to use Node core modules with Karma tests? Or is there some extra configuration I am missing?
karma.conf.js – This is only different from open-wc’s recommended config via test/**/*.test.js being changed to src/**/*.test.js.
const { createDefaultConfig } = require('#open-wc/testing-karma');
const merge = require('deepmerge');
module.exports = config => {
config.set(
merge(createDefaultConfig(config), {
files: [
// runs all files ending with .test in the test folder,
// can be overwritten by passing a --grep flag. examples:
//
// npm run test -- --grep test/foo/bar.test.js
// npm run test -- --grep test/bar/*
{ pattern: config.grep ? config.grep : 'src/**/*.test.js', type: 'module' }
],
// see the karma-esm docs for all options
esm: {
// if you are using 'bare module imports' you will need this option
nodeResolve: true
}
})
);
return config;
};
package.json:
"scripts": {
"test": "karma start",
"test:coverage": "karma start --coverage",
"test:watch": "karma start --auto-watch=true --single-run=false",
"test:update-snapshots": "karma start --update-snapshots",
"test:prune-snapshots": "karma start --prune-snapshots",
"test:compatibility": "karma start --compatibility all --auto-watch=true --single-run=false"
},
"devDependencies": {
"#open-wc/chai-dom-equals": "^0.12.36",
"#open-wc/testing": "^2.2.2",
"#open-wc/testing-karma": "^3.1.6",
"codecov": "^3.5.0",
"eslint": "^6.1.0",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-config-hughx": "^0.0.2",
"eslint-plugin-import": "^2.18.2",
"lit-html": "^1.1.1",
"webpack": "^4.38.0"
}
You cannot use core node modules in your karma tests unless you do something tricky. Karma tests run in the browser (even though the karma server runs on node). The tests therefore have no access to node core modules.
The only way to include node modules in your karma scripts is to use something like browserify or webpack.
But, more importantly, since the tests are running in the browser, you cannot access the file system directly. Your approach of trying to read a file on the disk will not work. You will need to be able to serve the file from your karma server using a fetch request or something similar.
You can specify where the karma server looks for resources using the basePath option in the configuration file.

Resources