I really need to have a period in either a parameter or a route but lite-server seems to object to this.
I have found several places referencing the issue and saying that it can be fixed with a rewrite rule but there are no complete examples that I can see that work.
For instance this answer: "dot" in query string parameter - AngularJS
The path that can have a dot in it is /report;url=example.com.
Based on above answer I editted bs-config.json to this:
{
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
},
"rewrites": [
{
"from": "/^\/report/",
"to": "index.html"
}
]
}
}
I also tried putting rewrites a level higher but neither had any effect on anything.
If I use navigate('report/', { url: 'value.with.dot' }) then I can use a period in the route or param and it works fine but I can't access it directly by typing in the url to browser.
I find lots of mentions on the internet about this being due to lite-server config but no straight forward example of what exactly to add to the lite-server config to fix it.
I am using Angular2.4 but i think this is problem specific to lite-server.
So essentially I need a rewrite rule to re-write the request to index.html but the way i have entered it has not worked.
Maybe just shield the dot, like this "example\.com"?
You should encapsulate inside a quotes
navigate('report/', { url: "'value.with.dot'" ))
Related
Unfortunately due to using cucumber and writing out scenarios I end up with incredibly long file names which windows complains about. Is it possible to override the naming for the files?
I'm assuming you're using the Nightwatch framework since you've tagged it in your post.
It looks like screenshot filenames are defined in nightwatch/lib/api/client-commands/end.js at line 26 of the latest repo const prefix = '${this.api.currentTest.module}/${this.api.currentTest.name}';.
The screenshot path is defined in your nightwatch.json:
{
"test_settings" : {
"default" : {
"screenshots" : {
"enabled" : true,
"on_failure" : true,
"path" : "./screens"
}
}
}
}
It appears your have a few options:
Modify the code in end.js to use a custom naming scheme, and live with a custom framework
Shorten your test module names or test names
Shorten your screenshot destination path in nightwatch.json - unlikely to solve anything since you're saying it's the filenames that are the problem.
This should be possible by using the filename_format option, since:
#2023 was merged
In my Chai tests I often find myself wanting to use their assertions that are something like .to.be.empty, .to.be.true e.t.c., because I find them to be cleaner to read than .to.be.length(1) or .to.be.equal(true). However, this breaks my linter (I'm using default Airbnb linting).
I could use the // disable-eslint-line syntax, but then I'd have to add it to every single line that reads like that and that seems tedious.
I've also read about the DirtyChai library, but that would require me to go back through my entire testing library adding brackets to them all which seems like something I shouldn't have to do simply to get my linter to pass something it should probably be OK with in the first place.
Does anyone know a nicer way to handle this than the ways I've outlined above?
You can disable the rule for the entire file using eslint-disable at the top of the file in question:
/* eslint-disable no-unused-expressions */
expect(someTrueValue).to.be.true;
However, adding this at the top of every test file can be tedious. To disable this rule for all relevant files, you can:
Put a new .eslintc configuration file in the same directory as your test files, configured to disable that rule. This allows you to use the default configuration for all other rules while ignoring that rule specifically only on files in that folder. ESLint calls this Configuration Cascading.
{
"rules": {
"no-unused-expressions": "off"
}
}
Use the overrides key in your main .eslintrc file to disable rules for groups of files with glob pattern matching:
{
"overrides": [
{
"files": ["*.test.js", "*.spec.js"],
"rules": {
"no-unused-expressions": "off"
}
}
]
}
This also allows you to disable other rules which become troublesome in testing, such as no-underscore-dangle when using rewire.
Just found another option using Relative Glob Patterns:
In your .eslintrc file:
"overrides": [
{
"files": "*.test.js",
"rules": {
"no-unused-expressions": "off"
}
}
]
I've made a small plugin called eslint-plugin-chai-friendly that overrides the default no-unused-expressions rule and makes it friendly towards chai. The modified rule ignores the expect and should statements while keeping default behavior for everything else.
Combining jonalvarezz's answer with Ihor Diachenko's answer gave me exactly what I wanted:
npm install --save-dev eslint-plugin-chai-friendly
// .eslintrc.js
module.exports = {
// ...
plugins: ['chai-friendly'],
overrides: [{
files: '*.test.js',
rules: {
'no-unused-expressions': 'off',
'chai-friendly/no-unused-expressions': 'error',
},
}],
// ...
}
This way, the no-unused-expression rule will only be overridden in *.test.js files
AND
a no-unused-expression rule will still be in place to catch any unused expressions in the test files that are unrelated to chai.
In case anyone is stumbling upon this today, I had the same issue and found this solution on eslint documentation. In your eslint configuration file, you can specify one or several environments, which will predefine global variables for this environment. For us, it'd be mocha, and you'd configure like this in your .eslintrc.json:
{
"env": {
"mocha": true
},
...
...
...
}
As a result, it will remove all false positive about mocha describe, it, beforeEach, etc. without needing to completely disable eslint or completely disable any specific rule.
Tested with ESLint v.4.11 and mocha 5.0
I had this issue with tslint and solved it by simply moving the rule for unused expressions down one level. My ./tslint.json has all the other rules I care about, then I made ./src/tslint.json that just looks like
{
"rules": {
"no-unused-expression": true
},
"extends": "../tslint.json"
}
tslint automatically checks for a config file in every level as it descends the tree (with --project or using the VSCode extension) so this means that my tests (under ./test/) have all the other rules applied, but no-unused-expression only applies to files under ./src/.
using SeedStack 14.7 we are facing a cache issue when uploading a new version on servers: every user have to clear their cache to get the last version of files.
I tried to use "urlArgs": "version=2" in the requireConfig part of the fragment JSON file. It do the job by adding argument on every files and so we can use it when changing version, but it also affect the urls in the config of each modules !
As we are using this config to pass the REST base url to each module, it breaks all REST requests by adding the argument to the base url.
My fragment JSON file :
{
"id": "mac2-portail",
"modules": {
"gestionImage": {
"path": "{mac2-portail}/modules/gestionImage",
"autoload": true,
"config": {
"apiUrl": "muserver/rest"
}
}
},
"i18n": {...},
"routes": {...},
"requireConfig": {
"urlArgs": "version=2",
"shim": {...}
}
}
Any idea to solve the cache issue without breaking REST requests ?
EDIT : it is not a duplicate of Prevent RequireJS from Caching Required Scripts. Yes SeedStack uses RequireJS and this configuration solve the cache issue, but it also affect other modules defined in the fragment so I need to find another solution to prevent browser to cache files
The module configuration values, like apiUrl in your example, are not touched by RequireJS unless you call require.toUrl() on them explicitly. I think this is what is happening in your case. To avoid this problem, you should always do the concatenation first and only then call require.toUrl() on the full resulting URL.
So, instead of doing:
var fullUrl = require.toUrl(config.apiUrl) + '/my/resource';
Do this:
var fullUrl = require.toUrl(config.apiUrl + '/my/resource');
By the way, instead of setting the version directly in the RequireJS configuration, you can simply add the version of your application to the data-w20-app-version attribute on the <html> element of the master page:
<html data-w20-app data-w20-app-version="2.0.0">
This will provide the same behavior but will work correctly in the case of Angular templates in $templateCache. If your master page is automatically generated by the backend, this is done automatically. Check this page for the details.
This is currently possible:
ember build --environment=production
... and I would like to do something like this instead:
ember build --environment=production --baseurl=foo
but config/environment.js only gets passed in the value of environment.
Is it possible to get the value of the other options passed in at the command line too?
You could set environment variables the old fashioned way (export WHATEVER=wee) from terminal or as part of a build script, then reference them in your Brocfile.js via node with process.env.WHATEVER. After that, it would be a matter of having broccoli do whatever it is you needed to do with them. You could pre-process files and replace strings, for example.
... just a suggestion. Not sure if that's what you're looking for or not.
It appears that this is not allowed:
Looking in node_modules/ember-cli/lib/commands/build.js, we see:
availableOptions: [
{ name: 'environment', type: String, default: 'development' },
{ name: 'output-path', type: path, default: 'dist/' }
],
... and in node_modules/ember-cli/lib/models/command.js
this.availableOptions.forEach(function(option) {
knownOpts[option.name] = option.type;
});
... which together mean that any options that are not defined, for each subcommand of ember, get discarded.
You can do foo=bar ember build (however doing ember build foo=bar doesn't work)
And the argument is available via process.env.foo.
To extend upon #ben's answer.
The raw command line arguments are available inside ember-cli-build.js and other files from the
process.argv.[]
So a command like this
ember build staging
you can access via:
process.argv.includes('staging')
see node's documentation for whats available.
https://nodejs.org/docs/latest/api/process.html
I want to show a default image in my widget. What is the best solution to point to an image which is located inside the widget folder structure?
require.toUrl("widgets.notes", "images/defaultAvatar.png"),
The output is:
htpp://www.example.com/widgets/main.notes 404 (Not Found)
Your call to require.toUrl is falsy, there are no second parameter taken.
Given that your modulepath to 'widgets' is set, instead do this:
require.toUrl("widgets/notes/images/defaultAvatar.png")
If you send simply the package namespace (e.g. 'widget'), it will try to make use of the CommonJS Package spec. You will notice in one of the informations that the standard minimum requirement is:
main - module that must be loaded when require(name) is called. Definition must be relative to the package description file.
Which is what require.toUrl("widgets") is interpreting.
One may however choose where the package 'root' should be looked for. So, if you have:
/
dojo/
dijit/
dojox/
widgets/
Then youre set from start with no interaction, 'widgets' is a global namespace pr definition. If it is not 'in-place' this is where dojo.registerModulePath (DEPRECATED as pr 1.7) comes in handy, see reference guide
If you have it set for another path (xdomain becomes really complicated however an absolute path is accepted) then you would do one of the two options here:
First an example layout of packages:
/ (webroot)
/dojo/
dojo-release-x.y/
dojo/
dijit/
dojox/
/widgets/
Option one is dojoConfig, set as window.dojoConfig prior to loading dojo.js script tag
var dojoConfig = {
packages: [
{
name: "widgets",
location: "/widgets" // note, 'http://mydomain.tld/widget' would work
}
]
};
Option two is as an additional, first parameter to require, like so:
require({
packages: [
{
name: "widgets",
location: "/widgets"
}
]
}, ["widgets/notes"], function(Notes) {
...
});
Check this out it worked for me
avatar: require.toUrl("widgets/MyFirstWidget/widget/images/edwin.jpg")
In the brackets start with the word widgets then forward slash followed by the complete url to the resource. Take for instance the example above, MyFirstWidget is the name of the widget and images is a folder i created inside widget to store image files