Comments (3)
To fix this issue just use latest version (v.0.0.4) of karma-json-fixtures-preprocessor
and setup it by using the new feature transformPath
:
jsonFixturesPreprocessor: {
variableName: '__json__',
transformPath: function(path) {
return path + '.js';
}
},
@billtrik: Could you update the instruction of "setup the karma-json-fixtures-preprocessor plugin" for using transformPath
, please? After this, this issue can be closed ;) Thanks!
from karma-fixture.
Hey @sectore, @MarcusVeres, i am trying to reproduce this but i cannot.
Let me add here that you did not provide enough info about the problem,
but instead only a proposed solution.
So, some background first:
Due to #7, i started using the json-fixtures-preprocessor
to load JSON files.
This preprocessor works by loading every file declared here:
preprocessors: {
...
'test/fixtures/**/*.json' : ['json_fixtures']
},
into the window.__json__
object in the test page.
For every json file loaded from the filesystem, it creates a key in this object like: "test/fixtures/some_other_folder/json_fixture_filename"
and the value is the contents of that file.
Note that the key does not include the '.json' suffix, as described in the problem. I checked every published version and i also used the mentioned transformPath
helper,
but it always does the same.
The key is always without the '.json' suffix.
Pretty straight forward stuff.
In this commit:
68bb717#diff-8d54b9a926c8d58538fac64c9aeefef7R50
i search for the requested json file trying out multiple combinations for the key string.
Specifically if you do a fixture.load('json_fixture.json');
the plugin with try the following keys on the __json__
object:
json_fixture
json_fixture.json
base/json_fixture
base/json_fixture.json
/absolute_fixture_path
So in my setup,
having done fixture.setBase('base');
and then fixture.load('json_fixture.json');
the requested json exists in window.__json__['base/json_fixture']
.
So in my mind, i cannot see where the problem might be.
Since @MarcusVeres has the same issue though, maybe there is something else here.
Prior to anything, please double check that you are using the latest version of karma-fixture.
Then put a debugger before your fixture.load()
line and check the key in the window.__json__
object. It's keys should include the base and then the filename without the '.json' suffix.
If not, maybe you have issues with how you declare which files to load in your config file.
If you still have a problem, please try to describe it as best as you can.
Finally since this is open source, it goes without saying that you are more than welcome to make a PR with a solution to this problem.
from karma-fixture.
I am closing this for now.
Will reopen it if there are still issues.
from karma-fixture.
Related Issues (20)
- Modifying loaded fixture data permanently modifies fixture data HOT 2
- Problem loading Karma-fixture using Jasmine HOT 2
- Same fixture object returned on multiple loads HOT 1
- Got unexpected token ":" when loading valid json file HOT 6
- Warning: No provider for "framework:fixture"! HOT 2
- Cannot find HTML fixtures. Cannot see an __html__ object HOT 2
- Multiple HTML fixtures with Jasmine / Babel, last loaded fixture overwrites all other loaded fixtures HOT 1
- Evaluate JS specified through 'src' attribute for <script> tag HOT 2
- Cannot find fixture error, unknown what to do to counter act this. HOT 16
- fixture.setBase() on global karma-shim.js HOT 4
- npm install fails on windows 7
- Auto-cleanup
- Cannot find fixture 'fixtures/div-foo.html' - fixture.load failing in beforeEach() with × "before each" hook for ... HOT 3
- Create new fixture container on cleanup
- fixture.clear() is really fixture.cleanup() HOT 1
- Throw error when fixture not found? HOT 3
- Modify base path? HOT 1
- Does not load json objects with escaped characters HOT 6
- Don't eval() text in <script> if type isn't "text/javascript" or "application/javascript"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-fixture.