#javascript #visual-studio-code
#javascript #visual-studio-code
Вопрос:
проблема, с которой я сталкиваюсь, заключается в том, что я не могу отладить свой код в Visual Studio code, я продолжаю получать ошибку ‘ReferenceError: описание не определено’, я не могу найти жизнеспособное решение для его работы, любая помощь была бы замечательной.
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/koans/AboutApplyingWhatWeHaveLearnt.js"
}]}
введите код здесь /Users/sambrandon/.nvm/versions/node/v12.18.3/bin/node ./koans/AboutApplyingWhatWeHaveLearnt.js
Отладчик прослушивает ws://127.0.0.1:49497/462da266-3a0b-453c-8130-d64c67860648
Для получения справки см.:https://nodejs.org/en/docs/inspector
Отладчик прилагается.
Ожидание отключения отладчика…
/Users/sambrandon/Desktop/Koon/seip2010-javascript-koans/коаны/О применении того, что мы узнали.js:4
описание(‘О применении того, что мы узнали’, функция() {
^
Ошибка ссылки: описание не определено в объекте. (/Users/sambrandon/Desktop/Koon/seip2010-javascript-koans/koans/aboutapplying whatwehavelearnt.js:4:1) в модуле._compile (internal/modules/cjs/loader.js:1137:30) в объекте.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) в модуле.загрузка (internal/modules/cjs/loader.js:985:32) в функцию.Модуль._load (internal/modules/cjs/loader.js:878:14) в Function.executeUserEntryPoint [как runMain] (internal/modules/run_main.js:71:12) во internal/main/run_main_module.js:17:47 Процесс завершен с кодом 1
var _; // globals
describe('About Applying What We Have Learnt', function() {
var products;
beforeEach(function () {
products = [
{ name: 'Sonoma', ingredients: ['artichoke', 'sundried tomatoes', 'mushrooms'], containsNuts: false },
{ name: 'Pizza Primavera', ingredients: ['roma', 'sundried tomatoes', 'goats cheese', 'rosemary'], containsNuts: false },
{ name: 'South Of The Border', ingredients: ['black beans', 'jalapenos', 'mushrooms'], containsNuts: false },
{ name: 'Blue Moon', ingredients: ['blue cheese', 'garlic', 'walnuts'], containsNuts: true },
{ name: 'Taste Of Athens', ingredients: ['spinach', 'kalamata olives', 'sesame seeds'], containsNuts: true }
];
});
/*********************************************************************************/
it('given I'm allergic to nuts and hate mushrooms, it should find a pizza I can eat (imperative)', function () {
var i, j, hasMushrooms;
var productsICanEat = [];
for (i = 0; i < products.length; i = 1) {
if (products[i].containsNuts === false) {
hasMushrooms = false;
for (j = 0; j < products[i].ingredients.length; j = 1) {
if (products[i].ingredients[j] === 'mushrooms') {
hasMushrooms = true;
}
}
if (!hasMushrooms) {
productsICanEat.push(products[i]);
}
}
}
expect(productsICanEat.length).toBe(1);
});
it('given I'm allergic to nuts and hate mushrooms, it should find a pizza I can eat (functional)', function () {
var productsICanEat = [];
/* solve using filter() amp; all() / any() */
// var pizzas = _(products.name).filter(function(x) {
// return _(products.name[x]).any('pizza');
// });
console.log(pizzas);
expect(productsICanEat.length).toBe(0);
});
/*********************************************************************************/
it('should add all the natural numbers below 1000 that are multiples of 3 or 5 (imperative)', function () {
var sum = 0;
for (var i = 1; i < 1000; i = 1) {
if (i % 3 === 0 || i % 5 === 0) {
sum = i;
}
}
expect(sum).toBe(FILL_ME_IN);
});
it('should add all the natural numbers below 1000 that are multiples of 3 or 5 (functional)', function () {
var sum = FILL_ME_IN; /* try chaining range() and reduce() */
expect(233168).toBe(FILL_ME_IN);
});
/*********************************************************************************/
it('should count the ingredient occurrence (imperative)', function () {
var ingredientCount = { '{ingredient name}': 0 };
for (i = 0; i < products.length; i = 1) {
for (j = 0; j < products[i].ingredients.length; j = 1) {
ingredientCount[products[i].ingredients[j]] = (ingredientCount[products[i].ingredients[j]] || 0) 1;
}
}
expect(ingredientCount['mushrooms']).toBe(FILL_ME_IN);
});
it('should count the ingredient occurrence (functional)', function () {
var ingredientCount = { '{ingredient name}': 0 };
/* chain() together map(), flatten() and reduce() */
expect(ingredientCount['mushrooms']).toBe(FILL_ME_IN);
});
/*********************************************************************************/
/* UNCOMMENT FOR EXTRA CREDIT */
/*
it('should find the largest prime factor of a composite number', function () {
});
it('should find the largest palindrome made from the product of two 3 digit numbers', function () {
});
it('should find the smallest number divisible by each of the numbers 1 to 20', function () {
});
it('should find the difference between the sum of the squares and the square of the sums', function () {
});
it('should find the 10001st prime', function () {
});
*/
});
Комментарии:
1. Можете ли вы опубликовать содержимое
Users/sambrandon/Desktop/Koon/seip2010-javascript-koans/koans/AboutApplyingWhatWeHaveLearnt.js
2. В основном файле может быть тест, начинающийся с описания. И я предполагаю, что вы не установили зависимости для распознавания описания
3. вам нужно
import
протестировать фреймворк, посмотрите пример в документе фреймворка