Declare p-dialog on #NgModule - angular8

When replicating this tutorial:
https://www.youtube.com/watch?v=VdxyZuysACc
I have the following error on Angular CLI :
"p-dialog is not a known element. Please add it to #NgModule".
I know that #NgModule belongs to an ".module.ts" file. I declared it there, under the metadata 'imports'. But do I also need to add in under the component's metadata tag 'providers' ?
Ty a lot!

Have you already added in app.module.ts declarations and entryComponents?:
#NgModule({
imports: [
...,
**YourDialogModule**
],
exports: [...],
providers: [...],
...
declarations: [**YourDialogComponent**],
entryComponents: [**YourDialogComponent**],
})
Don't forget to restart your web-app completely after the change.

Related

Nestjs can't resolve dependencies of the AppConfigService (Unit Testing)

I am trying to set up Jest Unit Testing to my project, but I'm getting the following errors when trying to Unit Test:
Erro Message (Screenshot)
How do I fix this issue?
You need to add some sort of mock/provider for the ConfigService. At the very least, this will make the test attempt to work.
{
provide: ConfigService,
useValue: {},
}
When you initialise the AppConfigService in test, you need to wire up the providers as well. If you dont need to mock you can directly provide the class in the providers list. If you need mocking, you can use the following dummy code. Refer here for nestjs testing documentation
providers: [
{
provide: AppConfigService,
useValue: createMock<AppConfigService>({
<method_name>: jest.fn(),
}),
},

Vue Nuxt I18n , the message properties it's not reflect directly when add new one or edit exist property

i have Nuxt project, when i try to add or edit message property it's not reflect direct, i should terminate the app and re-run it to see the results.
i followed the Nuxt Documentation and applied every single step
Edit your nuxt.config.js modules to look like this
modules: [
[
"#nuxtjs/i18n",
{
locales: [{ code: "en", name: "en-US", file: "en.json" }],
langDir: "locales/"
}
],
]
assuming your strings file is called en.json and it's inside locales/ like locales/en.json

Coverage reports 'Else path not taken' on an imported provider

I am losing my mind with the error. I am on react-native with jest (and no ts). I have a localization provider which exports several methods, including translations. translations is simply:
import LocalizedStrings from 'react-native-localization';
translations = new LocalStrings({en,de});
in my components, I do:
import { LocalizationContext } from './localization';
const { translations } = useContext(LocalizationContext);
now when running on my component, the whole import line is marked with about 6 E I E I
First, given I am only using translations, why are there more than one if and else to cover? and secondly, tranlations is set from LocalStrings of a third party library? should it even be tested?
I saw this question about jest config which advises about removing transform node from jest config but when i do it the whole test just stops with errors.
My jest config is:
{
"preset": "react-native",
"coverageReporters": [
"text",
"cobertura",
"lcov",
"json"
],
"moduleDirectories": [
"node_modules",
"src"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|#react-native-community/.*|react-navigation|react-navigation-drawer|#react-navigation/.*))"
]
}
My component simply outputs a provided value with no logic and there are no coverage notes at all except for the import.

vuejs use babel plugin-proposal-class-properties

I have a class where I use some static properties like this:
class Entity {
static LIMIT = 10;
}
So, i can do:
Entity.LIMIT
In order to do that I'm using babel plugin-proposal-class-properties and in my .babelrc I have:
{
"presets": ["#babel/preset-env"],
"plugins": [
["#babel/plugin-proposal-class-properties", { "loose": true }]
]
}
I'm using jest and my test passes using that config. Now I need to use funcionality of Entity class inside a vuejs component. But I got the error:
Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type
I also tried a babel config file in my project root: babel.config.js
module.exports = {
presets: ["#babel/preset-env"],
plugins: [
["#babel/plugin-proposal-class-properties", { "loose": true }]
]
};
But didn't work.
How can i configure vuejs, to make work this babel plugin?
I'm using vue2.6.11 and vue-cli 3
I got this exact same issue when trying to use "importabular" with vuejs (vuejs 2, vue-cli-3). Importabular uses class properties, after some research I found this babel plugins (plugin-proposal-class-properties), I installed it and added it in vue.config.js.
To finally make it work, I had to add "importabular" (or the nested path) in the transpileDependencies: option. Why that? Because, by default, Babel ignores whatever is in node_module, so you have to tell Babel to not ignore this specific folder.
So, if you want to use babel or some babel plugins with some node_module with vue you should modify the vue.config.js as follow :
module.exports = {
transpileDependencies: [
'path/in/node_module',
],
}
and change the babel.config.js as follow:
module.exports = {
"presets": [
"#vue/cli-plugin-babel/preset"
],
"plugins": [
["#babel/plugin-proposal-class-properties"],
]
}

Type Error global.XMLHttpRequest is not a constructor in NUXT

I am trying to use THIS library on the client side as a plugin When I npm run dev the client, I get this error
My vue2socketcluster.js file inside the plugins folder looks like this
import Vue2Socketcluster from 'vue2-socketcluster'
Vue.use(Vue2Socketcluster,{
hostname:"localhost",
secure:true,
propName:"socket" // Defaults to socket - so if you want vm.$soc you would change this to "soc"
})
and nuxt config had an entry for plugins
plugins: [
'~/plugins/vue2socketcluster'
],
Any direction will be super appreciated
Fixed it by setting server side rendering to false. Thank you
plugins: [
{ src: '~/plugins/sc', mode: 'client' }
],