Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma removes file when you save in Visual Studio #887

Open
ghost opened this issue Jan 15, 2014 · 13 comments
Open

Karma removes file when you save in Visual Studio #887

ghost opened this issue Jan 15, 2014 · 13 comments

Comments

@ghost
Copy link

ghost commented Jan 15, 2014

When you start Karma with autoWatch set to true and modify and save one of the files being watched in Visual Studio, Karma removes the file. This doesn't happen if you use Notepad++.

cmd

@vojtajina
Copy link
Contributor

That's probably because VS removes the file (I guess it moves the old file to a backup) and write a new file.
You might check out VS configuration, maybe you can disable it.

Does it always happen? Karma has a delay (by default 250ms) - it waits for any subsequent changes and batches them. I'm surprised that it's not enough. I would expect another "add file" event to be fired.

I think it's similar to #199.

@GiffenGood
Copy link

If you can, try watching a dir and not a single file. That fixed it for me.

@DanTup
Copy link
Contributor

DanTup commented Apr 9, 2014

Visual Studio does have strange behaviour (write a new file with a temp name, delete the old file, rename the temp file in its place). This was the cause of #959.

I've seen the behaviour described in this bug before; but it might've been on a previous version; don't think I've seen it on the latest version (with the fix for #959 included), but that's not to say it's not still there :(

@rabagast
Copy link

rabagast commented Sep 4, 2014

This is still the case, VS2013.3 . As GiffenGood says you can get around it by watching a dir and not the specific file. When I watched \dir*.js karma got into trouble with missing frameworks such as dojo in js-files I didn't want tested.

The way around this was to watch \dir\TestFile1*.js instead of \dir\TestFile1.js .

@dignifiedquire
Copy link
Member

Is this still an issue?

@rabagast
Copy link

We are still getting around this by watching TestFile1*.js (instead of TestFile1.js) and have forgotten all about it, so I do not know. I will not be back at work before late August and cannot verify before that.

@oocx
Copy link

oocx commented Sep 1, 2015

I also see this issue with Visual Studio 2015 and Karma 0.13.9

@rryter
Copy link

rryter commented Aug 2, 2016

This is also a problem in Intellij with Karma 1.1.2. Disabling the option 'save write' is my current "workaround".

@haroldrv
Copy link

This is still happening on Visual Studio 2015 (update 3) and karma 1.3.0, The workaround as mentioned by @GiffenGood is to watch a folder instead of single files

@wesleycho
Copy link
Member

Is this something that can be addressed by the library? This seems like not great behavior by these editors in question, and not sure there is anything that can be done about this.

@deejbee
Copy link

deejbee commented Dec 12, 2016

Unfortunately I don't seem to be able to use the suggested workaround as options.files accepts an array of either specific file names or a folder such as /project/*.js -but not a combination of both. I need to add a bunch of libraries at the top of the list of files, followed by the tests. e.g.:

 files: [
    'lib/angular.js',
    'components/**/(*.spec).js'
]

Or am I doing something wrong?

@wesleycho
Copy link
Member

@deejbee Karma uses https://github.com/isaacs/node-glob for pattern matching, so any valid glob patterns supported by the library work here.

@segl84
Copy link

segl84 commented Nov 27, 2018

Still an issue. If i have something like this...

files: [
    'myfile.js',
]

And myfile.js is removed and created during typescript build for example karma does not detect this as a change.

Workaround is okay... But more or less dirty. So a fix would be realy nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests