How to skip __mock__ folder while running strapi - unit-testing

I am working on writing unit tests for API written in strapi. So I create a mocks folder to mock firebase API call.
This code works well when I am running the test with jest but when I run the application with npm run develop it gives me below error
[2020-06-02T12:14:58.977Z] debug ⛔️ Server wasn't able to start properly.
[2020-06-02T12:14:58.978Z] error ReferenceError: jest is not defined
at Object.<anonymous> (/home/backend/Documents/workspace/proj/config/functions/__mocks__/firebase.js:1:23)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at module.exports.filePath (/home/backend/Documents/workspace/proj/node_modules/strapi/lib/load/require-file-parse.js:12:10)
at loadFiles (/home/backend/Documents/workspace/proj/node_modules/strapi/lib/load/load-files.js:35:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! proj#0.1.0 develop: `strapi develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the proj#0.1.0 develop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/backend/.npm/_logs/2020-06-02T12_14_58_985Z-debug.log
➜ proj git:(test) ✗
Is there any way to fix this issue ?

Related

django-tailwind, can't start dev server

I've done everything according to the django-tailwind docs, but when I want to start the dev server I get the following error:
> theme#3.1.1 start /home/amir/projects/planning-project/src/theme/static_src
> npm run dev
> theme#3.1.1 dev /home/amir/projects/planning-project/src/theme/static_src
> cross-env NODE_ENV=development tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css -w
/home/amir/projects/planning-project/src/theme/static_src/node_modules/tailwindcss/lib/cli.js:300
throw err;
^
TypeError: Object.fromEntries is not a function
at args (/home/amir/projects/planning-project/src/theme/static_src/node_modules/tailwindcss/lib/cli.js:243:47)
at Object.<anonymous> (/home/amir/projects/planning-project/src/theme/static_src/node_modules/tailwindcss/lib/cli.js:302:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! theme#3.1.1 dev: `cross-env NODE_ENV=development tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the theme#3.1.1 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/amir/.npm/_logs/2022-02-11T09_27_46_003Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! theme#3.1.1 start: `npm run dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the theme#3.1.1 start script.
I have tried going into "theme/static_src/src" directory and running npm run build-postcss, based on an answer on GitHub issue tracker, but then I get :
npm ERR! missing script: build-postcss
Turns out since I installed node via the standard servers it was an old version. You need to install a newer node version to solve this problem.

AWS Elastic Beanstalk invalid ELF Handler

I have been working on migrating a project from Heroku to AWS. I have been able to successfully upload the project onto AWS without any errors, however the applications health is listed as 'Degraded'. I have been reviewing my application logs and believe the issue has something to do with me writing the code on a Mac and then Elastic Beanstalk using a Linux AMI.
"invalid ELF header" when using the nodejs "ref" module on AWS Lambda
However, this post only diagnoses the issue. There is no solution provided. I am aware that there is an architectural mismatch when moving the code from Mac to Linux. I am looking for a solution to that problem.
Here are the error messages in my applications logs:
Error: /var/app/current/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (internal/modules/cjs/loader.js:730:18)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/var/app/current/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! beer#0.1.0 start: `node server/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the beer#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/.npm/_logs/2019-04-15T00_54_06_983Z-debug.log

Installing Electron on Windows 10 (`node-gyp rebuild` error)

I've seen a lot of Stack posts and GitHub posts on this, but I've hit a dead end and I'm not sure where else to turn (apologies if duplicate).
I'm following a guide here to install Electron. On the command npm install --runtime=electron --target=1.4.15, I hit the common stack:
> msgpack#1.0.2 install D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\msgpack
> node-gyp rebuild
D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\msgpack>if not defined npm_config_n
ode_gyp (node "C:\Users\User Name\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp
\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://iojs.org/download/release/v1.4.15/iojs-v1.4.15.tar.gz
gyp ERR! stack at Request.<anonymous> (C:\Users\User Name\AppData\Roaming\npm\node_modules\npm\node_modules\node
-gyp\lib\install.js:210:14)
gyp ERR! stack at emitOne (events.js:101:20)
gyp ERR! stack at Request.emit (events.js:188:7)
gyp ERR! stack at Request.onRequestResponse (C:\Users\User Name\AppData\Roaming\npm\node_modules\npm\node_module
s\request\request.js:1074:10)
gyp ERR! stack at emitOne (events.js:96:13)
gyp ERR! stack at ClientRequest.emit (events.js:188:7)
gyp ERR! stack at HTTPParser.parserOnIncomingClient (_http_client.js:473:21)
gyp ERR! stack at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
gyp ERR! stack at TLSSocket.socketOnData (_http_client.js:362:20)
gyp ERR! stack at emitOne (events.js:96:13)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User Name\\AppData\\Roaming\\npm\\node_modules\\n
pm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\msgpack
gyp ERR! node -v v6.10.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN gnomics# No description
npm WARN gnomics# No repository field.
npm WARN gnomics# No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! msgpack#1.0.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the msgpack#1.0.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User Name\AppData\Roaming\npm-cache\_logs\2017-09-25T04_40_03_337Z-debug.log
The guide suggests building from the source by running npm install --global --production windows-build-tools, which runs successfully, but even after clearing the cache, the Electron install command still produces the same error.
I have Python2.7 in my PATH variable and PYTHON variable, as suggested by some Stack answers.
Funny enough, running npm config -g set msvs_version 2015 followed by npm i worked. Then running the Electron install command seemed to work, until I ran the test ./node_modules/.bin/electron, which produced:
D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\electron\index.js:9
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
^
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at Object.<anonymous> (D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\electron
\index.js:9:9)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\electron
\cli.js:3:16)
at Module._compile (module.js:570:32)
This is all being run on a x64 Windows 10 system. I've tried everything above on Windows PowerShell (as admin and not as admin), on command prompt (as admin and not as admin), and on Git Bash, all with the same error messages.
Any help would be much appreciated! (If any additional info is needed, such as Microsoft Visual Studio, SDK, or other installs, please let me know which ones and I'll updated accordingly).
EDIT 1: Just of note, running everything as a single command, i.e. npm install --global --production --runtime=electron --target=1.4.15 --build-from-source windows-build-tools also doesn't work (well the install completes without error, but Electron still says that it failed to install correctly).
UPDATE 1: Okay, so I deleted everything and cleared the cache and then I ran npm config -g set msvs_version 2015, followed by npm i, and then npm install --runtime=electron --target=1.4.15. Next I ran ./node_modules/.bin/electron which worked. But then, launching the actual project created a new Electron error... So I don't think I "solved" anything really. The new error was:
D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\bindings\bindings.js:83 Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\zmq\build\Release\zmq.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at bindings (D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\bindings\bindings.js:76:44)
at Object.<anonymous> (D:\Research Documents\Fall 2017 - Work\Lab Work\sample_app\node_modules\zmq\lib\index.js:6:30)

Meteor 1.4.4.1 issues running on AWS Beanstalk

After upgrading to Meteor 1.4.1.1 I can run my Meteor app without issues locally, but once uploaded to AWS Beanstalk, I am getting the error below. Any help greatly appreciated. (Uninstalling/ReInstalling Meteor did no help). I am using meteor build --server-only ../build --architecture os.linux.x86_64 command to build on Windows if that matters and then deploying to AWS Linux instances.
Error: Cannot find module 'fibers'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/app/current/programs/server/boot.js:1:75)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
npm ERR! Linux 4.4.51-40.60.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v7.6.0-linux-
x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v7.6.0-linux-
x64/bin/npm" "start"
npm ERR! node v7.6.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE

parse server elastic beanstalk 502 error

I have gotten my parse server to upload to elastic beanstalk, but when I click the URL to my application on aws eb I get a 502 error every time. I have PARSE_SERVER_APPLICATION_ID,database uri, master key, and server url "serverurl"/parse.yet I am still getting this error. please help.
> parse-server#2.2.15 start /var/app/current
> node ./bin/parse-server
module.js:327
throw err;
^
Error: Cannot find module '../lib/cli/parse-server'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/app/current/bin/parse-server:3:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
npm ERR! Linux 4.4.14-24.50.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/npm" "start"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! parse-server#2.2.15 start: `node ./bin/parse-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the parse-server#2.2.15 start script 'node ./bin/parse-server'.
npm ERR! This is most likely a problem with the parse-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/parse-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs parse-server
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls parse-server
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log