I am trying to explicitly import only to fix linting errors, similar to using
var describe = require("describe").mocha
is there a similar import for only?
As mentioned by jonrsharpe, to fix linting errors, you should configure your linter properly instead of fixing them in code.
However, to answer your question, you can import specific method like this.
var only = require('mocha').describe.only
var describe = require('mocha').describe
// If you import describe, you get everything beneath too so you can do
only = describe.only // This will be the same as L1 provided that you have describe
On a sidenote, if you use eslint, eslint-plugin-mocha is worth a look in order to configure your linter for mocha.
Related
I'm using Amplify with flutter, I wanna write a query and limit the data being queried, I looked into the documentation https://docs.amplify.aws/lib/datastore/data-access/q/platform/flutter#pagination and found this code snippet:
List posts = await Amplify.DataStore.query(Post.classType,
pagination: new QueryPagination(page:0, limit:100));
But unlike the snippet I'm not able to invoke QueryPagination to feed data into page and limit attributes, I viewed the source of pagination attribute of query and found that QueryPagination class is defined but I don't know how to invoke it.
Issue image
Thank you for reading, please help me out
For anyone else having the same issue this should help you out: try importing manually:
import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart';, I found the solution here: https://github.com/aws-amplify/amplify-flutter/issues/500
I experienced a similar issue.
import
import 'package:amplify_datastore/amplify_datastore.dart';
or
import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart';
if the issue still persists, then restart your IDE. This was the solution that eventually worked for me.
I use babel 7.8.3 together with #babel/preset-env, useBuiltIns: 'usage' and corejs: 3. The documentation for #babel/preset-env is not clear to me.
Do I need to add the following lines at the top of my entry file or is it done automatically by babel?
import 'core-js/stable';
import 'regenerator-runtime/runtime';
According to babel-preset-env docs you should import those modules by yourself
Don't need to add import code by yourself when use usage.
And no more need to manually include the regenerator-runtime helper when compiling generators after babel/core >= 7.18
I am trying to import a simple node js module into Ember js. I followed the quick start at https://guides.emberjs.com/v3.8.0/getting-started/quick-start/ and got the People List working.
Then I added the simple upper-case module using npm install upper-case and added app.import('node_modules/upper-case/upper-case.js'); to ember-cli-build.js as mentioned in https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/.
After that, I opened scientists.js and added import to upper-case as follows:
import Route from '#ember/routing/route';
//import uc from 'upper-case';
export default Route.extend({
model() {
var arr = new Array();
arr[0] = 'Marie Curie'; // uc('Marie Curie');
arr[1] = 'Mae Jemison';
arr[2] = 'Albert Hofmann';
return arr;
}
});
If I remove the comments, it shows me a blank screen. If I use 'Marie Curie'.toUpperCase() it works, but I want to be able to import such node modules. How can I achieve this?
I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.
PS: I could make upper-case work in other JS frameworks such as React and Vue, so the module itself doesn't have any issues.
if you install ember-auto-import, you'll be able to use any npm package like how the particular npm package's documentation says to use it (provided the particular npm package is configured correctly on build).
https://github.com/ef4/ember-auto-import
This'll be a default soon (and is recommended over using app.import)
The reason ember-auto-import is recommended over app.import is because there are ~ 5 different module formats JS can exist in, and you need to worry about those when using app.import. ember-auto-import, powered by webpack, abstracts all that away from you.
fwiw, JS has .toUpperCase() built in: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
so you don't need that particular module.
Edit
I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.
did you get any errors with this?
I have a python structure like this:
mymodule/
globalconfig.py # variables to set environment, etc
work.py # has: from mymodule.globalconfig import *
__init__.py
tests/
testspart1/
test_work.py # has: from mymodule.work import *
From inside work.py, all is well and I can access my global config variables and functions.
From inside test_work.py, I cannot access those variables, even if I add a second import,
from mymodule.globalconfig import *
Why is this? I wanted to use the same syntax as used in my modules.
thank you!
I am using py2.7 and, to get nice rspec-style outputs and verbose diffs,
pytest --spec -vv
Ref;
1.This answer reminded me I could use another format of import. If there are no other answers I will post my workaround. how to share a variable across modules for all tests in py.test
The import syntax that worked for me was directly importing the nested python file in addition to importing the file under test.
from mymodule.work import *
import mymodule.globalconfig as myconfigs
I assume it's a name clash or import circularity issue, but I could not figure out what the problem was. It took me a while so I wanted to be sure to post the solution for future me and others.
With a proper intersphinx setup, you can link to Django classes from your own documentation like this:
:class:`django:django.db.models.Model`
But how do you link to a setting? Django uses its own :setting: construct for that instead of something build-in like :class:. How do I link to a setting with intersphinx?
I've tried various incantations, but none work (and some are probably plain wrong):
:ref:`django:ROOT_URLCONF`
:ref:`django:root_urlconf`
:setting:`django:ROOT_URLCONF`
:ref:`django:setting:ROOT_URLCONF`
:django:setting:`ROOT_URLCONF`
Errors like undefined label: django:root_urlconf and Unknown interpreted text role "setting" greet me.
The problem: my local sphinx did not know about Django's custom sphinx roles, like setting. So a perfectly fine intersphinx reference like this:
:django:setting:`ROOT_URLCONF`
does not work until you've told Sphinx about the intersphinx target's custom role.
In the end got it working by copying a small snippet from Django's sphinx extension as _ext/djangodocs.py next to my documentation:
def setup(app):
app.add_crossref_type(
directivename = "setting",
rolename = "setting",
indextemplate = "pair: %s; setting",
)
And I added the following to my Sphinx' conf.py:
import os
import sys
...
sys.path.append(
os.path.abspath(os.path.join(os.path.dirname(__file__), "_ext")))
# ^^^ I'll do that neater later on.
extensions = ['djangodocs',
# ^^^ I added that one.
'sphinx.ext.autodoc',
...
]
...
So: intersphinx works, but if you point at a custom role, you need to have that custom role defined locally.
You need to look at the objects.inv for django to figure out what the correct cross reference should be.
It appears that:
:std:setting:`ROOT_URLCONF <django:ROOT_URLCONF>`
should work.
Somehow I have the objects.inv for django but can't find the URL I retrieved it from, in theory it should be https://docs.djangoproject.com/en/1.4/objects.inv but that redirects several times eventually resulting in a file-not-found error.