My unit tests for my React project pass perfectly fine on local but fail on Jenkins.
I get this error message on Jenkins:
Error: Cannot find module '../../../../src/components/Sidebar/MenuList.jsx'
The file does exist and is imported in my test file like so:
import { MenuList } from '../../../../src/components/Sidebar/MenuList.jsx';
And exported in my MenuList.jsx file:
export class MenuList extends Component { ... }
I am using Mocha/Enzyme/Sinon for testing + Istanbul for coverage.
Since you have a mac and im guessing jenkins is a linux based.
Check the file names. meaning check that the names are case sensitive.
Your problem is that the mac is not case sensitive while the jenkins (im guessing) is in a linux host which is. so say you have a file name like this
import a from '../MyCoolDir'
and the dir name is '../myCoolDir' it will work on mac but not on your jenkins. since the linux host will not be able to find the file becase it does not have the exact name
Youll probably want to take a look at this to configure git too
How do I commit case-sensitive only filename changes in Git?
Hope it helps
Related
I want to develop a React app for work in a directory and copy the bundle file over to a local instance of our website, which runs on a Django backend in a different directory on my local file system. But, of course, I can quickly develop in one directory and copy the bundle to another directory using my file system. Still, I was hoping to automate this each time I compiled.
I have written a plugin for my webpack config file and can read the bundle and write it to a separate file within the project directory (using the fs package). Still, I can't find a way to write the copy to a different directory on my file system. So it either ends up in the project directory I am compiling from, or I get an error.
Error: ENOENT: no such file or directory
Is such a thing possible? For example, I suppose I could write the bundle to the other directory in the first place and not copy it if the webpack output can write to a different location.
Here is the code for my plugin in my webpack.config.js so far. In this example, I was trying to write it to the desktop for testing, but ultimately I would like to put it in a different directory.
class Copy {
apply(compiler) {
compiler.hooks.afterEmit.tap('Copy', (compilation) => {
//const file = compilation.getAsset('bundle.js')
//console.log(file.name)
let string = fs.readFileSync('./static/js/bundle.js')
fs.writeFile('/Users/<username>/Desktop/bundle.js', string, (err) => {
if (err) throw err
console.log(err)
})
})
}
}
I've tried multiple options for the path in the fs.writeFile function such as the whole absolute path C:/Users/<username>/Desktop/bundle.js and have tried it with and without the leading / though I believe it needs one if I don't provide the drive letter.
Any help would be appreciated.
Figured out what the path should actually be. I am running WSL2 on Windows 10 and compiling via webpack on a linux terminal. If I provide the full directory using WSL syntax
/mnt/c/Users/<username>/Desktop/bundle.js
for example, I can write the bundle where it needs to go.
I have a big problem that often confuses me.
From time to time, while importing code, the import does not work and the development environment does not find the files. I work at IntelliJ IDEA.
To find a file, I first export it:
export let Filename =
and I import in the file necessary for me, but when I register a file name, ide for me does not look and it is necessary to write independently. But when I write the path to a file manually, I get the error that there is no such file. What could be the problem?
I have installed Jest in my react project. This is the scaffolding of one component:
ComponentFolder
__test__
unit.spec.js
snapshot.spec.js
utils.js
index.js
At the beginning I had have just one file of test (unit) and the utils and everything worked fine but when I have added the second spec file (snapshot), jest is returned me an error:
Your test suite must contain at least one test.
So I guess I should remove the utils file form the test folder but like this I will lose the structure, because that utils file is used just for tests in order to create the component with different status.
It's hard to know without seeing what's in the files, but I'm guessing your newly added snapshot.spec.js doesn't have an it block, the it block is improperly formatted, or it doesn't contain an assertion like expect(func()).toMatchSnapshot().
I am new to Go and AppEngine. I am trying to figure out how to create packages but I keep running into conflicts. My directory structure is below:
GOPATH
third-party-libs
app
app.yaml
controllers
default.go -- package controllers
models
models.go -- package models
templates
templates.go -- package templates
I am importing the templates package as follows import ("app/templates") inside default.go
When I do goapp serve I get this error:
Failed parsing input: app file templates.go conflicts with
same file imported from GOPATH
I have tried a bunch of things and nothing has worked so far. These are things I have tried:
Changed the templates directory to apptemplates and the corresponding file to apptemplates.go, changed package name to apptemplates. I imported it as app/apptemplates
I tried different combinations by changing the file name but not the package name, vice versa, etc. Either it does not find the file or has a conflict.
I am importing html/template in my templates.go file. So I commented out the entire file just keeping the package declaration but did not make the conflict go away
I thought may be another file is named templates.go but when I do this (at the GOPATH level) find . -name "*.go" | grep "templates.go" I only see the one file I have created.
I am confused as to how packages are created. I have changed the name to something generic so it does not look like a naming issue. Can someone please tell me how I can debug this error?
Thanks!
Rename the package to a non-conflicting name as in #1. Import the package using the path "apptemplates".
Packages inside of the application directory (the directory containing app.yaml) are imported with a path relative to the application directory. See Organizing Go Apps for the complete details.
I am still new to Python and GAE. I have an application on local server that is running just fine. I can add entity to my datastore, I can view my website, etc: everything is fine.
Now I am trying to use bulkloader to add entities to my datastore. I followed the tutorial at https://developers.google.com/appengine/docs/python/tools/uploadingdata. My loader is below:
from google.appengine.ext import ndb
from google.appengine.tools import bulkloader
import my_model
class ArticleLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'Article',
[('title', str),
('author', str)
])
loaders = [ArticleLoader]
I am getting the error:
No module named my_model
Does anyone have a fix for this?
Note: I am only using one directory. So my loader is in the same location as the other file that imports the my_model module.
This can also happen if your PYTHONPATH is not properly set up. If you're on Linux, try running this before you run the Bulkloader:
export PYTHONPATH=$PYTHONPATH:.
This appends your current directory to your PYTHONPATH and should make your my_model module visible. Since my memory is terrible and I always forget to do it, I've ended up using a simple shell script that includes this at the beginning and then the bulkload command itself.
If you're on Windows, you should be able to modify your path by using sys.path.append. Haven't tested this, but you could try adding this to your script (note that this should work on Linux as well):
import sys
# ...
sys.path.append('.')
Your code should be located in a file named my_model.py. You are getting that error because there is no module named my_module. Might be worth a read of the Python module and package docs.