Cypress.moment using locale - automated-tests

I am trying to use Cypress.moment to compare dates. The targeted website is in french so the date format.
Therefore, I intended to use moment.js method to switch fr locale.
Cypress.moment.locale('fr')
I should be able to do that as they say on cypress documentation :
Cypress automatically includes moment.js and exposes it as Cypress.moment
https://docs.cypress.io/api/utilities/moment.html#Syntax
Then,
const todaysDate = Cypress.moment().format('Do')
const currentMonth = Cypress.moment().format('MMMM')
cy.get('.date__title').should('contain', todaysDate)
cy.get('.c-title').should('contain', currentMonth)
But the assertion fails as cypress refuse to take into account the fr locale. It keeps comparing 'décembre' with 'december' for instance. Which fails obviously.
I am doing something wrong ?

in the same aforementioned thread, a working answer recently surfaced:
put this in support/index.js:
Cypress.moment.locale('de');
it worked brilliantly in my project

Unfortunately, at the time of writing, I think this is not possible with Cypress.moment.locale(), as you can see in this issue in their git repository.
As commented there moment.locale requires an import in addition to the standard moment import, that import is moment-with-locales.min.js and has not been included in Cypress.

Related

Does clouds.yaml work with python-api cinderclient as well?

I noticed by accident that openstack.connect() automatically tries to access the clouds.yaml file. I tried to replicate this for the cinderclient, but it didn't work. I know of no documentation of that feature, therefore I just guessed:
from cinderclient import client
from keystoneauth1 import loading
loader = loading.get_plugin_loader('password')
auth_cinder = loader.load_from_options()
I also tried the other load commands given by loading, but none of them worked without further parameters like openstack.connect() did.
If I just missed the full documentation of this feature, I would love to be pointed towards the right direction.

Is there a way to import multiple enumerands in IBM Rhapsody?

I have an enumerand of around 150 entries, which I need to get into IBM Rhapsody.
Doing this by hand is clearly lengthy and error prone. I have google extensively but found only things that tell me how to edit the generated code -- not go the other way.
The question is: How is this done? And if there is no way -- please someone post that as an answer.
David,
I would jump into the Java API (plugin subsystem) and do it that way. If you haven't learned how to use the API, there is a bit of a learning curve. There are two ways to go about it: Implement a Java (or your favorite JVM language--I use Scala) app that realizes the Rhapsody Plugin framework and then you choose to package it up and deploy it so that it gets loaded when you load your model, or, if it is a one off job, do everything up to the point of packaging it up and then run it from within your IDE and you are done. If you are comfortable with Scala, I can post some code.
So what I did in the end was I edited the relevant .sbs file, used a small python program to generate the items I required, and then update the length of the array accordingly.
all_the_literals = ["enum_name = 0x4e", enum_name2 = 0xF2", ... ,]
for field1, waste, field1_value in map(lambda x: x.split(" "),
all_the_literals):
literal_string = f""" {{ IEnumerationLiteral
- _id = GUID {uuid.uuid4()};
- _name = \"{field1}\";
- codeUpdateCGTime = 5.16.2022::19:24:18;
- _modifiedTimeWeak = 5.16.2022::19:24:18;
- _value = \"{field1_value}\";
}}"""
print(literal_string)
Note the above "code" snippet purely prints the items, which you then copy-paste into the relevant field in the sbs file. YMMV -- this was the correct format for an enum in Rhapsody (and note how I fudged the update time, but it worked successfully, so you'll need to do the same if you use this answer).
Also note it's probably better to use bauhaus9's answer, but I definitely didn't have time for it.

VaadinServlet.getCurrent returns null

I have a Vaadin7 application I am trying to move to Vaadin12 and there is a line of code where I call VaadinServlet.getCurrent() to get the servlet ( I actually need to configuration information ). It is returning null. What is happening and how can I fix?
Obviously, this line of code works fine in Vaadin7.
Ok, it was a simple solution: I just had to change import com.vaadin.server.VaadinServlet; to import com.vaadin.flow.server.VaadinServlet;. There is a addon we use that seems to reference vaadin 7 stuff, and thus neither of us noticed the wrong import statement. Either we should have stopped using this addon or updated it to the latest version.
Lesson to learn from this: make sure you are no referencing Vaadin 7 via depencies in your pom, I guess.

NativeScript Playground: moment.js npm package included but error requiring moment

I just started experimenting with Nativescript and am using the Playground to test things and see how it works.
What I wanted to do: add the moment.js module for formatting date/time
What I tried:
1. added the moment package. This appears to have worked because Playground now shows the moment folder along with files (package.json, ender.js, moment.js, etc) and subfolders.
2. In my code I used this snippet to require "moment"
var Moment = require("moment");
This failed though because I get an error of
Error: Could not find module 'moment'. Computed path '/var/mobile/Containers/Data/Application/xxxx/Documents/Playground/LiveSync/app/tns_modules/moment'
Any suggestions on what I need to change to get it to find 'moment'? I checked in package.json and it has the name as "moment".
The default require statement will search for the module form the tns_modules directory that was packed with the app during build time. So with Playground you could use relative path.
For example, if you want to use it on app.js which is in the root level,
var Moment = require('./moment');

is there any way to import third party JS into mongoJS...?

I am looking for a function to convert UTC timestamp to another timezone timestamp.
It needs two parameters,
utcTimestamp(1464891132) &
timezoneString("Asia/Kolkata")
function convertToTimeZone(utcTimestamp, timezoneString) {
//do some operations and
return "timestamp in given timezone";
}
I just checked link and found that there are some js libs, which solve that conversion problem, but now my problem is how can I import third party js to my mongoJS.
Or is there any patch or alternative to solve these problem in mongojs?
FYI I am using mongoJS from mongoshell....

Resources