Я пытаюсь проверить свою базу данных, используя Жасмин.Я использую PostgreSQL с Sequelize.Я тестирую модель:
fishtype.js
import { sequelize, DataTypes } from '.';
const FishType = sequelize.define(
'FishType',
{
name: {
type: DataTypes.STRING(50),
allowNull: false,
unique: 'fishType_unique'
}
}
)
FishType.associate = function ({ FishingSpot }) {
FishType.hasMany(FishingSpot, {
foreignKey: {
name: 'fishingSpotId',
allowNull: true
},
as: 'fishingSpots',
})
}
export default FishType;
Мой файл spec.js:
fishtype.spec.js
import FishType from '../../models';
describe('FishType', () => {
it('should be accessed', () => {
console.log(FishType.count())
return FishType.count().then((count) => {
expect(count).toEqual(0);
});
});
})
После начала тестирования я получаю следующую ошибку:
Failures:
1) FishType should be accessed
Message:
TypeError: _models2.default.count is not a function
Stack:
at <Jasmine>
at UserContext.<anonymous> (E:/js/fishing-app/server/spec/model/fishType.spec.js:6:26)
at <Jasmine>
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)