I have a quite big solution with a few web module projects (they are kind of modules and they are copied into a common project which is the SPA). I started to write jasmine-typescript tests against my angular 1.5.8 code. In order to spare copying time I need to set up Chutzpah for every web project so I can test every module code.
I have the chutzpah.json below and this way when I select "Open in Browser" then I can see the tests.
{
"Framework": "jasmine",
"FrameworkVersion": "2",
"Compile": {"Mode": "External"},
"References": [
{
"Path": "../../where_angular_and_other_scripts_are_placed/",
"Includes": [ "*.js" ]
},
{
"Path": "../../where_angular-mocks_are_placed/",
"Includes": [ "*.js" ]
},
{
"Path": "../../CommonLibrary/",
"Includes": [ "*.js" ],
"Excludes": [ "*.Spec.js" ]
},
{
"Path": "app/modules/Framework/",
"Includes": [ "*.Spec.js" ]
}
]
}
If I change the file like below then there are no tests. I don't understand why. Chutzpah cannot manage that a solution has more than one chutzpah.json in different directories? According to the documentation it shouldn't be problem.
{
"Framework": "jasmine",
"FrameworkVersion": "2",
"Compile": {"Mode": "External"},
"References": [
{
"Path": "../../where_angular_and_other_scripts_are_placed/",
"Includes": [ "angular.js", "*.js" ]
},
{
"Path": "../../where_angular-mocks_are_placed/",
"Includes": [ "*.js" ]
},
{
"Path": "../../CommonLibrary/",
"Includes": [ "*.js" ],
"Excludes": [ "*.Spec.js" ]
}
],
"Tests": [
{
"Path": "app/modules/Framework/",
"Includes": [ "*.Spec.js" ]
}
]
}
Another issue with Chutzpah setup is that, it always says that angular is not defined. I have the code below and when I run it it says angular is not defined. If I remove the inject part then it runs. But, I need to mock things. I have the bad feeling the above configuration issue and the stuff below somehow connected.
describe("getActiveModules method", (): void =>
{
var RestangularMock: any;
var angularCommonCheckerService:AngularCommonCheckerService;
var dilibModuleService: IDiLibModuleService;
var $q: ng.IQService;
var allReturnObject: any;
beforeEach((): void =>
{
//#region Arrange
angular.mock.inject(($injector): void => {
$q = $injector.get("$q");
});
RestangularMock = jasmine.createSpyObj("Restangular", ["all", "post"]);
angularCommonCheckerService = new AngularCommonCheckerService();
dilibModuleService = new DilibModuleService(RestangularMock, angularCommonCheckerService);
var returnList: IModuleContract[] = [
<IModuleContract>{ id: 100, isActive: 1 },
<IModuleContract>{ id: 101, isActive: 1 },
];
var allReturnObject = <any>{
getList: (): IModuleContract[]> => {
var deferred = $q.defer();
deferred.resolve(returnList);
return deferred.promise;
}
};
spyOn(allReturnObject, "getList");
//#endregion
});
it("should call Restangular resource with given string", (): void =>
{
RestangularMock.all.and.returnValue(allReturnObject);
dilibModuleService.getActiveModules();
expect(RestangularMock.all).toHaveBeenCalledWith("FrameworkApp/Module/GetActiveModules");
expect(allReturnObject.getList).toHaveBeenCalledTimes(1);
});
Questions:
Why Chutzpah doesn't list tests when the test references listed under "Test"? Did I do something wrong?
Is the issue around inject connected to the configuration issue?
how can I debug Chutzpah and see what is included from the references and tests? It is enough to check the source of the generated html file?
Related
I'm very new to Strapi and GraphQL. I have created a nested data structure in Strapi that looks like this (this is a Navbar component). But when I go to GraphQL, my query looks like this.
So if this is the query:
query MyQuery {
allStrapiNavbar {
nodes {
Category {
Name
children {
id
}
}
}
}
}
This is the result:
{
"data": {
"allStrapiNavbar": {
"nodes": [
{
"Category": [
{
"Name": "Community",
"children": []
},
{
"Name": "Modules",
"children": []
},
{
"Name": "Company",
"children": []
},
{
"Name": "Pricing",
"children": []
}
]
}
]
}
},
"extensions": {}
}
This means the data is being fetched correctly. However, I can't find the nested component 'Item' inside 'Category'.
This is what my gatsby-config.ts file looks like currently:
{
resolve: "gatsby-source-strapi",
options: {
apiURL: process.env.STRAPI_API_URL || "http://localhost:1337",
queryLimit: 1000, // Default to 100
accessToken: process.env.STRAPI_TOKEN,
collectionTypes:[ 'faq', 'doc', 'docCategory', 'faqCategory', 'release', 'userType' ],
// contentTypes: [ 'Faq' ],
singleTypes: [ 'navbar' ],
},
I don't know why the data isn't showing up in GraphQL. I looked inside the children for Category, but the reality is that it should be at the same level as Name, which shows up.
Do I need to modify the gatsby-config file, or am I missing something else?
Edit: I am using the gatsby-source-strapi plugin.
I have custom skill that calls web service i created. I am able to launch and get other intent, but i am not getting notification when permission for notification is changed by user of my skill. I need he notification event to get user id for sending push notifications later by other service.
Below is my json file:
{
"manifest": {
"apis": {
"custom": {
"endpoint": {
"uri": "https://pathToMyService",
"sslCertificateType": "Wildcard"
},
"interfaces": []
}
},
"events": {
"publications": [
{ "eventName": "AMAZON.TrashCollectionAlert.Activated" },
{ "eventName": "AMAZON.MessageAlert.Activated" }
],
"subscriptions": [
{ "eventName": "SKILL_PROACTIVE_SUBSCRIPTION_CHANGED" },
{ "eventName": "SKILL_ENABLED" },
{ "eventName": "SKILL_DISABLED" },
{ "eventName": "SKILL_PERMISSION_ACCEPTED" },
{ "eventName": "SKILL_PERMISSION_CHANGED" },
],
"regions": {
"NA": {
"endpoint": {
"uri": "https://pathToMyService",
"sslCertificateType": "Wildcard"
}
}
},
"endpoint": {
"uri": "https://pathToMyService",
"sslCertificateType": "Wildcard"
}
},
"manifestVersion": "1.0",
"permissions": [
{ "name": "alexa::devices:all:notifications:write" }
],
"publishingInformation": {
"locales": {
"en-US": { "name": "Test Events" }
}
}
}
}
Below is the Launch request: I have truncated applicatioId, userID, consentToken, deviceId, apiAccessToken
{"version":"1.0","session":{"new":true,"sessionId":"amzn1.echo-api.session.60ad1e76-0872-4e10-b79d-7144cdf3e1c9","application":{"applicationId":"amzn1.ask.skill.59d60703"},"user":{"userId":"amzn1.ask.account.AGB7EOY","permissions":{"consentToken":"eyJ0eXAiOiJKV1"}}},"context":{"System":{"application":{"applicationId":"amzn1.ask.skill.59d60703"},"user":{"userId":"amzn1.ask.account.AGB7EOY","permissions":{"consentToken":"eyJ0eXAiOiJKV1Qi"}},"device":{"deviceId":"amzn1.ask.device.AFNXDZOAEMFDFKK","supportedInterfaces":{}},"apiEndpoint":"https://api.amazonalexa.com","apiAccessToken":"eyJ0eXAiOiJKV1Qi"}},"request":{"type":"LaunchRequest","requestId":"amzn1.echo-api.request.adb318af-1977-4b36-b8ad-0bb4352fa563","timestamp":"2020-03-22T23:37:55Z","locale":"en-US","shouldLinkResultBeReturned":false}}
Thanks
I resolved the issue: When I updated by skill.json file using
ask api update-skill -s amzn1.ask.skill.59d6 -f Test.json
it didn't update properly. I noticed today when I got latest
ask api get-skill -s amzn1.ask.skill.59d6 >Test2.json
the event section was missing. I added back and reapplied and it's working now.
I'm using the Firefox WebExtensions API with the following background script
var log = console.log.bind(console)
log('hello world from browser extension')
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onCompleted
var filter = { urls: '<all_urls>' }
var extraInfoSpec = ['tlsInfo', 'responseHeaders']
browser.webRequest.onCompleted.addListener(function(details){
log(`Woo got a request, here's the details!`, details)
}, filter, extraInfoSpec)
log('Added listener')
After loading the script from about:debugging, I see the following output in DevTools:
hello world from browser extension
I do not see any output- there is no data from browser.webRequest.onCompleted.addListener and there is no 'Added listener' message.
How do I make browser.webRequest.onCompleted work?
For completeness, my manifest.json is below:
{
"manifest_version": 2,
"name": "Test extension",
"version": "1.0",
"description": "Test extension.",
"icons": {
"48": "icons/border-48.png"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"permissions": [
"webRequest",
"webRequestBlocking"
]
}
The webRequest API is only available to background scripts. You seem to using it inside a content script.
urls in var filter = { urls: '<all_urls>' } needs to be be an array ['<all_urls>'].
'tlsInfo' in extraInfoSpec doesn't exist, I don't know where it comes from.
You need to specify an additional <all_urls> permission in your manifest.
script.js
var filter = { urls: ['<all_urls>'] }
var extraInfoSpec = ['responseHeaders']
browser.webRequest.onCompleted.addListener(function(details){
console.log(`Woo got a request, here's the details!`, details)
}, filter, extraInfoSpec)
console.log('Added listener')
manifest.json
{
"manifest_version": 2,
"name": "Test extension",
"version": "1.0",
"description": "Test extension.",
"icons": {
"48": "icons/border-48.png"
},
"background": {
"scripts": ["script.js"]
},
"permissions": [
"webRequest",
"webRequestBlocking",
"<all_urls>"
]
}
Im trying to use react loadable with server side rendering.
My babel plugins config
"plugins": [
"syntax-dynamic-import",
"dynamic-import-node",
"react-loadable/babel",
[
"import-inspector",
{
"serverSideRequirePath": true,
"webpackRequireWeakId": true
}
],
"transform-react-remove-prop-types",
"transform-react-inline-elements",
"transform-react-constant-elements"
]
server response during rendering, with:
console.log(modules);
const bundles = getBundles(stats, modules);
console.log(bundles);
gets:
[ 'HomePage' ]
[ undefined ]
i guess my error comes from react-loadable.json which has one of the keys undefined
"undefined": [
{
"id": 7,
"name": "./node_modules/react-intl/lib/index.es.js",
"file": "main.a77d1cb1913eab1806a7.js"
},
{
"id": 19,
"name": "./node_modules/redux/es/index.js",
"file": "main.a77d1cb1913eab1806a7.js"
},
{
"id": 52,
"name": "./node_modules/redux-saga/es/internal/sagaHelpers/index.js",
"file": "main.a77d1cb1913eab1806a7.js"
}
]
but i can figure out how it becomes undefined if i have webpackChunkName and modules defined like this:
export default Loadable({
loader: () => import(/* webpackChunkName: "HomePage" */ './index'),
loading: () => null,
modules: ['HomePage'],
});
maybe someone had similar problem or know any solution?
I'm having trouble getting to object in json file.
I'm using
.controller("ListController", ["$scope", "$http", function($scope, $http){
$http.get('../scripts/bbtv.json').success(function(data) {
$scope.artists = data;
});
}])
The data gets in the variable, but I can't access any object of it. Here is part of the json file. For example how to print out {{programmeField.titleField.valueField}} ?
{
"channelField": [
{
"displaynameField": [
{
"valueField": "bTV"
}
],
"idField": "BBTV"
}
],
"programmeField": [
{
"titleField": [
{
"langField": "BULG",
"valueField": "Тази сутрин"
}
],
"subtitleField": [],
"creditsField": {
"moderatorField": [
"Антон Хекимян"
]
},
"categoryField": [
{
"langField": "BULG",
"valueField": "Информационно предаване"
},
{
"langField": "BULG",
"valueField": "Сутрешен блок"
}
],
"languageField": {
"valueField": "BULG"
},
"lengthField": {
"unitsField": 1,
"valueField": "180"
},
"videoField": {
"presentField": "yes",
"colourField": "yes",
"aspectField": "4:3",
"qualityField": "800x600"
},
"audioField": {
"presentField": "yes",
"stereoField": "no",
"dolbyDigitalField": "no",
"dolbySurroundField": "no"
},
"startField": "20151216063000 +0200",
"stopField": "20151216093000 +0200",
"channelField": "BBTV",
"clumpidxField": "0/1",
"_photos": [
{
"_id": "5f38a2ab2fedd6b0e48da60b833bb4ddb69d3a1c",
"_url": "***.jpg",
"_type": "Letterbox"
}
],
"_deleted": false,
"_id": "189397717",
"_contentId": 45207610,
"_broadcastdate": "20151216"
}
}
JSON is a transport format. Once it's decoded, it's a native data structure, like any other structure. Since you're in JS, use JS conventions, and follow the bracketing/bracing. Note the labelling on the objects/arrays below:
data = { "channelField": [
a b
{ "displaynameField": [
c d
{ "valueField": "bTV"
e
}
],
"idField": "BBTV"
data.channelField[0].displaynameField[0].valueField -> "bTV"
a b c d e
Since your "programmeField" and "titleField" are array, use programmeField[0].titleField[0].valueField
In future you can copy your json to http://jsonviewer.stack.hu/ and the click on the Viewer tab.