Error thrown in test by formatter
sudo-suhas opened this issue · comments
I get the following error during a test:
sets direct_generator option
E:\Projects\repos\elastic-builder\node_modules\concordance\lib\formatUtils.js:106
Error thrown in test:
Error {
message: 'Formatter buffer can only take one formatted value.',
}
SingleValueFormatter.append (node_modules/concordance/lib/formatUtils.js:106:30)
format (node_modules/concordance/lib/diff.js:175:44)
Object.diffDescriptors (node_modules/concordance/lib/diff.js:338:11)
Test.setsOption (test/_macros.js:170:11)
Specifically this test - https://github.com/sudo-suhas/elastic-builder/blob/master/test/suggesters-test/phrase-suggester.test.js#L49
I am making use of macros and the test is a t.deepEqual(value, expected);
. I tried to log the value
and expected
and they are identical:
{
"my_suggester": {
"phrase": {
"direct_generator": [
{
"field": "title.trigram",
"suggest_mode": "always"
}
]
}
}
}
I can't figure out why I am getting the error.
Good find. #34 should solve this.
I tried to log the value and expected and they are identical:
They're not, actually. Here's the fixed output:
{
my_suggester: {
phrase: {
direct_generator: [
- DirectGenerator {
- _body: {
- field: 'title.trigram',
- suggest_mode: 'always',
- },
- },
+ {
+ field: 'title.trigram',
+ suggest_mode: 'always',
+ },
],
},
},
}
Comparisons take into account object constructors.
Anyway, this is a discussion that's better to be had in the AVA repository.
@novemberborn Thanks! And you are absolutely right. I actually logged using JSON.stringify
. Since the child object implements toJSON
, the stringified representation was same but not the actual value. I don't get the errors after the bug fix for this.