#quasar/extras/mdi-v4 jest unit testing failing on Unexpected token 'export' - jestjs

I am using the new SVG images. I have created a test for a header that contains a logo, name mdiMenu.
import { mdiMenu } from '#quasar/extras/mdi-v4'
But everything I am running the test: I always get this error:
SyntaxError: Unexpected token 'export'
29 |
30 | <script>
> 31 | import { mdiMenu } from '#quasar/extras/mdi-v4'
Do somebody else have encounter this problem and how can I solve this?
This is the rest of the error message:
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
C:\Users\YohnCheung\work\bitBucket\central-station\node_modules\#quasar\extras\mdi-v4\index.js:3
export const mdiAbTesting = 'M4 2A2 2 0 0 0 2 4V12H4V8H6V12H8V4A2 2 0 0 0 6 2H4M4 4H6V6H4M22 15.5V14A2 2 0 0 0 20 12H16V22H20A2 2 0 0 0 22 20V18.5A1.54 1.54 0 0 0 20.5 17A1.54 1.54 0 0 0 22 15.5M20 20H18V18H20V20M20 16H18V14H20M5.79 21.61L4.21 20.39L18.21 2.39L19.79 3.61Z'
^^^^^^
Question was taken from:
https://forum.quasar-framework.org/topic/5459/quasar-extras-mdi-v4-jest-unit-testing-failing
https://forum.vuejs.org/t/quasar-extras-mdi-v4-jest-unit-testing-failing/89973

Correct transformation need to be set.
So you need to configure jest.config.js correctly
...
transform: {
'^.+\\.jsx?$': require.resolve('babel-jest'),
},
...
My jest config is extending preset
preset: '#vue/cli-plugin-unit-jest/presets/typescript-and-babel',
which already includes this transform, but also sets not to transform pacages from node_modules
transformIgnorePatterns: ['/node_modules/'],
reference: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-unit-jest/presets/default/jest-preset.js
therefore in my config I have changed pattern to
transformIgnorePatterns: ['node_modules/(?!(quasar|quasar/*|#quasar|#quasar/*))'],
so it ignores all packages but quasar's
Hope this answer will help someone :)

Related

In search of the mysterious skipped Jest test

We have the following output at the end of our Jest test base:
Test Suites: 273 passed, 273 total
Tests: 1 skipped, 1923 passed, 1924 total
Snapshots: 61 passed, 61 total
Time: 38.885 s, estimated 39 s
You see there is one skipped test.
When I search my test files either for it.skip or test.skip or generally skip I find nothing.
What I also tried is outputting the test run into JSON via:
jest --json --outputFile=testrun.json
In the top of the file I find this information:
{
"numFailedTestSuites": 0,
"numFailedTests": 0,
"numPassedTestSuites": 273,
"numPassedTests": 1923,
"numPendingTestSuites": 0,
"numPendingTests": 1,
"numRuntimeErrorTestSuites": 0,
"numTodoTests": 0,
"numTotalTestSuites": 273,
"numTotalTests": 1924,
...
}
so it looks like that numPendingTests is the one pointing to the skipped one. But when I search the output file, again, no trace of a skipped test. In fact, I did a search for "status": "[a-z]and there is no other status to be found than passed.
Short of looking through 270+ test suites, how else could a skipped test hide from me? Is there any way to find it?
As mentioned by johnrsharp as a comment, another way to skip tests in Jest is to prefix the term it(test) with x- so if you want to scan the files for skipped tests, you also need to look out for xit or xtest.

Pushing Results to KiwiTCMS using RobotFramework Ride Issue

I am trying to get Robotframework(Ride) work with KiwiTCMS.
I am making the connection to the KIWI server (local) but I am getting these errors that I am not sure where(In RIDE? or the .conf file?) to fix:
[ ERROR ] Calling method 'start_suite' of listener 'zealand.listener.KiwiTCMS' failed: ENVIRONFILE Version value not defined, missing one of TCMS_PRODUCT_VERSION, TRAVIS_COMMIT, TRAVIS_PULL_REQUEST_SHA or GIT_COMMIT
[ ERROR ] Calling method 'end_test' of listener 'zealand.listener.KiwiTCMS' failed: TypeError: 'NoneType' object is not subscriptable
TestKiwiRide | PASS |
------------------------------------------------------------------------------
KiwiTest.TestKiwi | PASS |
1 test, 1 passed, 0 failed
==============================================================================
KiwiTest | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output: C:\Users\hendri\Documents\KiwiTest\output.xml
Log: C:\Users\hendri\Documents\KiwiTest\log.html
Report: C:\Users\hendri\Documents\KiwiTest\report.html
(kiwi-env) C:\Users\hendri\Documents\KiwiTest>
Please assit?
Details goes into the bat file you use to call the test cases
check here : https://kiwitcms.readthedocs.io/en/stable/plugins/automation-frameworks.html
In plugin configuration section, you have to passe configuration as environment variables. e.g.
export TCMS_PLAN_ID=*PLAN_ID*

How to install npm packages in BigQuery?

I unfortunately can not any reliable documentation on how to use an npm package in BigQuery. I want to use the package isitblocked in BigQuery and parse the URLs in my tables through the library.
I only found this blog, but I can't re-procedure the steps there and get the following error while using webpack:
`assets by status 390 bytes [cached] 1 asset
./index.ts 2.43 KiB [built] [code generated] [1 error]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to > 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable > defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in ./index.ts 1:16
Module parse failed: Unexpected token (1:16)
You may need an appropriate loader to handle this file type, > currently no loaders are configured to process this file. See > > https://webpack.js.org/concepts#loaders
import envPaths = require("env-paths");
| import Listr = require("listr");
| import fs = require("fs-extra");
\
The package I try to install is isitblocked.
I did it step by step in the google Shell and it prompted to install the webpack. Please include the mode none or production
npx webpack --config webpack.config.js --mode none
Then upload the file under dist and edit the BigQuery query to:
CREATE TEMP FUNCTION get_rand_card_number()
RETURNS STRING
LANGUAGE js
OPTIONS (
library=["gs://***your*bucket*name***/creditcard-generator.js"]
)
AS r"""
return webpackNumbers.GenCC("Amex"); # Still wrong function name
""";
CREATE TEMP FUNCTION get_rand_id()
RETURNS STRING
LANGUAGE js
AS r"""
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 4 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(4);
});
""";
SELECT
x,
get_rand_id() as unique_id,
get_rand_card_number() as credit_card_number
FROM
unnest(generate_array(1,100,1)) x

Fail2ban custom regular expresion

Trying to add custom rule on regular expression in order to block the below log.
Mar 17 18:46:52 s21409974 named[1577]: client #0x7g246c107030 1.1.1.1#8523 (.): query (cache) './ANY/IN' denied
I did tried with online tools like this one (https://www.regextester.com) but on the fail2ban-regex test command does display like it miss it.
Any suggestion about the rule or about how to better troubleshoot?
Thank in advance
Why do you try to write a custom regex? This message is pretty well matching with original fail2ban filter named-refused:
$ msg="Mar 17 18:46:52 s21409974 named[1577]: client #0x7g246c107030 1.1.1.1#8523 (.): query (cache) './ANY/IN' denied"
$ fail2ban-regex "$msg" named-refused
Running tests
=============
Use failregex filter file : named-refused
Use single line : Mar 17 18:46:52 s21409974 named[1577]: client #0x7...
Results
=======
Prefregex: 1 total
| ^(?:\s*\S+ (?:(?:\[\d+\])?:\s+\(?named(?:\(\S+\))?\)?:?|\(?named(?:\(\S+\))?\)?:?(?:\[\d+\])?:)\s+)?(?: error:)?\s*client(?: #\S*)? (?:\[?(?:(?:::f{4,6}:)?(?P<ip4>(?:\d{1,3}\.){3}\d{1,3})|(?P<ip6>(?:[0-9a-fA-F]{1,4}::?|::){1,7}(?:[0-9a-fA-F]{1,4}|(?<=:):)))\]?|(?P<dns>[\w\-.^_]*\w))#\S+(?: \([\S.]+\))?: (?P<content>.+)\s(?:denied|\(NOTAUTH\))\s*$
`-
Failregex: 1 total
|- #) [# of hits] regular expression
| 1) [1] ^(?:view (?:internal|external): )?query(?: \(cache\))?
`-
Ignoreregex: 0 total
Date template hits:
|- [# of hits] date format
| [1] {^LN-BEG}(?:DAY )?MON Day %k:Minute:Second(?:\.Microseconds)?(?: ExYear)?
`-
Lines: 1 lines, 0 ignored, 1 matched, 0 missed
[processed in 0.01 sec]
But if you need it, here you go (regex interpolated from fail2ban's pref- & failregex):
^\s*\S+\s+named\[\d+\]: client(?: #\S*)? <ADDR>#\S+(?: \([\S.]+\))?: (?:view (?:internal|external): )?query(?: \(cache\))? '[^']+' denied
replace <ADDR> with <HOST> if your fail2ban version is smaller than 0.10.

You may need an appropriate loader to handle this file - .net core & Angular

I keep getting the following error web running a production build of a .net core angular 4 application. Those are 2 node packages I installed and looks like their is some issue with webpack reading those files only for production builds. Any thoughts?
ERROR in ./$$_gendir/~/ngx-mydatepicker/dist/ngx-my-date-picker.component.ngfactory.ts
Module parse failed: d:\a\1\s\Vacant2\$$_gendir\node_modules\ngx-mydatepicker\dist\ngx-my-date-picker.component.ngfactory.ts Unexpected token (14:28)
You may need an appropriate loader to handle this file type.
| import * as i3 from 'ngx-mydatepicker/dist/directives/ngx-my-date-picker.focus.directive';
| import * as i4 from 'ngx-mydatepicker/dist/services/ngx-my-date-picker.util.service';
| const styles_NgxMyDatePicker:any[] = ['.ngxmdp .headertodaybtn,.ngxmdp .monthcell,.ngxmdp .weekdaytitle{overflow:hidden;white-space:nowrap}.ngxmdp *{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:Arial,Helvetica,sans-serif;padding:0;margin:0}.ngxmdp .selector{position:absolute;padding:0;border:1px solid #CCC;border-radius:4px;z-index:100000;animation:selectorfadein 60ms}.ngxmdp .selector:focus{border:1px solid #ADD8E6;outline:0}#keyframes selectorfadein{from{opacity:0}to{opacity:1}}.ngxmdp .selectorarrow{background:#FAFAFA;padding:0}.ngxmdp .selectorarrow:after,.ngxmdp .selectorarrow:before{bottom:100%;border:solid transparent;content:" ";height:0;width:0;position:absolute}.ngxmdp .selectorarrow:after{border-color:rgba(250,250,250,0);border-bottom-color:#FAFAFA;border-width:10px;margin-left:-10px}.ngxmdp .selectorarrow:before{border-color:rgba(204,204,204,0);border-bottom-color:#CCC;border-width:11px;margin-left:-11px}.ngxmdp .selectorarrow:focus:before{bord...
| export const RenderType_NgxMyDatePicker:i0.RendererType2 = i0.ɵcrt({encapsulation:2,
| styles:styles_NgxMyDatePicker,data:{}});
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts 10:0-115
# ./ClientApp/boot.server.ts
ERROR in ./$$_gendir/~/ngx-loading/ngx-loading.ngfactory.ts
Module parse failed: d:\a\1\s\Vacant2\$$_gendir\node_modules\ngx-loading\ngx-loading.ngfactory.ts Unexpected token (12:35)
You may need an appropriate loader to handle this file type.
| import * as i1 from 'ngx-loading';
| import * as i2 from '#angular/common';
| export const LoadingModuleNgFactory:i0.NgModuleFactory<i1.LoadingModule> = i0.ɵcmf(i1.LoadingModule,
| ([] as any[]),(_l:any) => {
| return i0.ɵmod([i0.ɵmpd(512,i0.ComponentFactoryResolver,i0.ɵCodegenComponentFactoryResolver,
# ./$$_gendir/ClientApp/app/components/app/app.component.ngfactory.ts 9:0-94
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts
# ./ClientApp/boot.server.ts
I found the solution here https://github.com/aspnet/JavaScriptServices/issues/1168#issuecomment-320026397
Just needed to remove include: /ClientApp/ from myh webpack.config.js.

Resources