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

Exclude directories? #128

Closed
amandapouget opened this issue Feb 20, 2018 · 11 comments
Closed

Exclude directories? #128

amandapouget opened this issue Feb 20, 2018 · 11 comments

Comments

@amandapouget
Copy link

Is there any way to exclude directories in the configuration?

E.g. spec_files:

Sorry I can't find this anywhere else!

Thank you!

@slackersoft
Copy link
Member

I'm not totally sure what you're looking to exclude here. Do you want to not supply the spec_files key in your jasmine.json? Or do you want to add a large glob and then another rule to remove things from that glob?

@amandapouget
Copy link
Author

amandapouget commented Mar 1, 2018 via email

@slackersoft
Copy link
Member

slackersoft commented Mar 1, 2018

Ok, that makes sense. We would be happy to review a pull request that changes the behavior of the file loading code to allow a glob starting with ! to cause previously included files to be excluded.
So a config that includes:

{
  spec_files: [
    '**/*spec.js',
    '!foo/**/*.js',
    'foo/really/*.js'
  ]
}

Would include all the files under spec_dir that end with spec.js, except any files in the foo directory, but allow anything in foo/really.

@cancerberoSgx
Copy link
Contributor

I'm trying to use the command line to filtering specs but with no luck. I want to call jasmine from cmd line but I tried and tried to use --filter and seems it accept regex and not a glob. Will try to investigate and make a PR for this. Is pretty common wanting to filter specs from CLI, for example from project's package.json "test" . Do you known if I can filter using globs ? thanks

@slackersoft
Copy link
Member

@cancerberoSgx The --filter command line argument isn't meant for filtering files, but to limit which specs found in all of your spec files will be executed by Jasmine. This is why it doesn't accept globs. The Jasmine-npm package currently accepts files as the last argument on the command line, and this should work with globs just fine.

Hope this helps. Thanks for using Jasmine!

@cancerberoSgx
Copy link
Contributor

OK now I got it , by looking at the code... I just created this one #131 to add a small comment about filtering because at least for me was not clear and hard to find this info that IMO is important. Thanks and keep the good work!

@slackersoft
Copy link
Member

#131 is merged. We would still be happy to review a pull request to allow ! style globs in the spec_files option as mentioned previously.

@cancerberoSgx
Copy link
Contributor

cancerberoSgx commented Apr 19, 2018

In general what I've seen for supporting this, is having two properties, "include" and "exclude". Current "spec_files" would be "include" and any file that matches any of the globs will be included. Then if any of the "exclude" glob matches the file it won't be included, not matter if it matches the "include" one. I've seen this in typescript tsconfig.json, vscode settings and others

If you don't want to define another property in jasmine.json, then the only way I see is doing kind of "Magic" and treat specially those globs that starts with "!". Won't be an OR anymore... Personally I don't like that - I would introduce another property like "spec_files_exclude".

My two cents

@slackersoft
Copy link
Member

I don't have a problem with an exclude only filter.

The advantage of the ! syntax is it leaves the priority up to the user to enable a bunch of things, eliminate a folder, but still include something in that folder if desired.

The other advantage of the ! syntax is it is easily portable to the other file lists in the config, so helpers could also benefit from this ability without another extra key in the config.

Neither of these arguments are super strong though, so I would also be happy to see a pull request that added an excluded_spec_files or something.

@liuxh0
Copy link
Contributor

liuxh0 commented Oct 2, 2018

What is current state of this issue? Would like to help if still not done.

In my opinion the ! variant is okay since it doesn't introduce another property. But:

  • I don't think it is a good idea to let order decide priority due to complexity. If you want to include something in a folder but eliminate the rest of the folder, I would do something like folder/**/*.spec.ts, instead of first eliminating the whole folder and then including files wanted.

@slackersoft
Copy link
Member

To my knowledge no work has been started for this issue. I still don't have a strong preference on which mechanism is used to allow exclusion of files/folders, so if you want to take a look at this, you're welcome to use either approach.

liuxh0 added a commit to liuxh0/jasmine-npm that referenced this issue Oct 7, 2018
Paths in spec_files and helpers starting with ! will be excluded
from respectively spec files and helper files.

jasmine#128
liuxh0 added a commit to liuxh0/jasmine-npm that referenced this issue Oct 7, 2018
Paths in spec_files and helpers starting with ! will be excluded
from respectively spec files and helper files.

jasmine#128
liuxh0 added a commit to liuxh0/jasmine-npm that referenced this issue Oct 7, 2018
Paths in spec_files and helpers starting with ! will be excluded
from respectively spec files and helper files.

jasmine#128
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

4 participants